Ethereum Development Toolset
With Ethereum Development Toolset, you can easily:
Change config values in the file config.js
to make it works:
contractSourcePath
: the path of folder that contains your .sol source filesbuiltContractPath
: the build target folder pathdeployedContractPath
: the path of folder to save deployed contracts informationnetworks
: define networks to deploy and interact with deployed smart contracts.
Each network is in an entry of `networks` dictionary: `network_id: {...}`
_For example_:
```
dev: {
url: "http://localhost:8545",
defaultAccount: {
address: '0x...',
privateKey: 'Your account private key'
},
gas: 6500000
}
```
Run the following command in your terminal:
node compile.js
That will compile all .sol
files in the contractSourcePath
.
Each contract’s bytecode and definition will be saved as <builtContractPath>/<contract_name>.json
file.
We will support compile single .sol
file in the future.
Run the following command in your terminal:
node deploy.js --contract=YourContractName [ --network=targetNetworkId ] [ --params='[param1, param2,...] ]'
In that:
networks
) that you want to deploy the contract to.
If skipped, the net work id `default` will be used.
Skip this if the smart contract's constructor has no parameter.
This finds the contract <builtContractPath>/YourContractName.json
definition (generated by compile process) to deploy contract to the selected network.
The deployment information (contract address, transaction hash,… ) will be saved to <deployedContractPath>/YourContractName_<networkId>.json
.
For example:
node deploy.js --contract=TradeLog --network=dev --params='[12345, "Mr Fun"]'
(if success, deployment info will be saved as <deployedContractPath>/TradeLog_dev.json
)
Run in the terminal:
node invoke.js [ --network=networkId ] --contract=YourContractName --method=methodName --verb=call|send [ --params='[param1,param2]' ]
This will use the contract deployment info (from file <deployedContractPath>/YourContractName_<networkId>.json
generated by the deployment process)
to build the contract and invoke the method.
Example:
node invoke.js --network=dev --contract=TradeLog --method=recordTrade --verb=send --params='["000001","EUR", "USD", 2]'
node invoke.js --network=dev --contract=TradeLog --method=getTradeRecord --verb=call --params='["000001"]'