项目作者: namisoft

项目描述 :
Ethereum Development Toolset
高级语言: JavaScript
项目地址: git://github.com/namisoft/eth-toolset.git
创建时间: 2019-05-27T03:09:08Z
项目社区:https://github.com/namisoft/eth-toolset

开源协议:MIT License

下载


eth-toolset (Ethereum Development Toolset)

With Ethereum Development Toolset, you can easily:

  • Compile your smart contract code into binary code that is ready for deployment
  • Deploy your compile smart contract to Ethereum networks
  • Invoke smart contract methods from console (commandline) for testing purpose

Configuration

Change config values in the file config.js to make it works:

  • contractSourcePath: the path of folder that contains your .sol source files
  • builtContractPath: the build target folder path
  • deployedContractPath: the path of folder to save deployed contracts information
  • networks: define networks to deploy and interact with deployed smart contracts.
    1. Each network is in an entry of `networks` dictionary: `network_id: {...}`
    2. _For example_:
    3. ```
    4. dev: {
    5. url: "http://localhost:8545",
    6. defaultAccount: {
    7. address: '0x...',
    8. privateKey: 'Your account private key'
    9. },
    10. gas: 6500000
    11. }
    12. ```

Compile smart contract(s)

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.

Deploy smart contract

Run the following command in your terminal:

node deploy.js --contract=YourContractName [ --network=targetNetworkId ] [ --params='[param1, param2,...] ]'

In that:

  • —contract (required): your contract name
  • —network (optional): the Id of network (defined in the config key networks) that you want to deploy the contract to.
    1. If skipped, the net work id `default` will be used.
  • —params (optional): the parameters’s values that will be passed to the smart contract’s constructor.
    1. 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:

  1. node deploy.js --contract=TradeLog --network=dev --params='[12345, "Mr Fun"]'

(if success, deployment info will be saved as <deployedContractPath>/TradeLog_dev.json)

Invoke smart contract method

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:

  • Invoke send method: node invoke.js --network=dev --contract=TradeLog --method=recordTrade --verb=send --params='["000001","EUR", "USD", 2]'
  • Invoke call method: node invoke.js --network=dev --contract=TradeLog --method=getTradeRecord --verb=call --params='["000001"]'