This demo adapts the Web3j quickstart HelloWorld example to send 1000 contract creations in quick succession. This code manages the nonce and uses the encoded contract data to create a transaction, sign and send it without waiting for transaction receipts.
It is intended to test behaviour of an Ethereum network for development/testing purposes.
The following environment variables can be set, otherwise their default value in parentheses will be used.
- WEB3J_NODE_URL ("http://localhost:8545") - point this at your Ethereum network
- WEB3J_WALLET_PASSWORD ("")
- WEB3J_WALLET_PATH" ("test-wallet.json")
test-wallet.json is included in this project, it was created with the web3j cli web3j wallet create
Your running Ethereum network may need to allocate this wallet's address some funds for the contract creation to work.
This project can also use raw private key instead of wallet file. Manually assign org.web3j.Web3ContractCreation.USE_PRV_KEY_CREDS
to true
and update value of org.web3j.Web3ContractCreation.TEST_PRV_KEY
If it's your first run, you'll need to generate the HelloWorld contract wrapper:
./gradlew generateContractWrappers
Alternatively, you can use your own contract following the instructions below.
Finally, run Web3ContractCreation.main
- Add your .sol contract to src/main/solidity
- Run
./gradlew generateContractWrappers
- In
Web3ContractCreation.main
, changeHelloWorld.BINARY
to your contract wrapper's binary