Skip to content

Latest commit

 

History

History
97 lines (58 loc) · 1.78 KB

README.md

File metadata and controls

97 lines (58 loc) · 1.78 KB

wanchain-sc-sdk

SDK for deploying smart contracts on Wanchain.

Installation

Use NPM or Yarn to install the package:

npm install --save wanchain-sc-sdk

Configuration

Before deploying smart contracts, some config items are required.

  • network
  • Choose to deploy on "mainnet" or "testnet", default is mainnet.

  • wanNodeURL
  • Wanchain node for web3 to connect and send transactions, http and wss connections are supported, default is iWan.

  • privateKey
  • Private key of deployer. No default.

  • contractDir
  • Contracts source code directory, it should be absolute path, can include subfolders. No default.

  • outputDir
  • Directory to output deployment information, it should be absolute path, default is homedir of user.

  • gasPrice
  • Default is 180 Gwin.

  • gasLimit
  • Default is 8 million.

    APIs

  • config
  • Config SDK.

  • compile
  • Compile a contract, can be skipped if contract name is consistent with it's source file name and not need to link any library.

  • link
  • Link libraries to a contract, can be skipped if not need to link any library.

  • deploy
  • Deploy a contract.

  • sendTx
  • Send a transaction to contract.

  • deployed
  • Get a instance of contract which is deployed before.

    Usage

    Step 1: Create a deployment script file, deploy.js for example.

    Step 2: Import wanchain-sc-sdk package.

    const deployer = require('wanchain-sc-sdk');

    Step 3: Config the deployer.

    const cfg = {
      privateKey: 'your-private-key',
      contractDir: 'contracts-directory',
      ......
    }
    deployer.config(cfg);

    Step 4: Compose deployment scripts.

    example

    Step 5: Start to deploy.

    node deploy.js