Deploy Smart Contract

Step 1: Obtain Contract Source

Generate a seleton smart contract using dipc-init, and fill the business logic you need in the contract.

dipc-init -project example -bare

If you do not use the dipc-init tool, you need to introduce the “dipc/dipc.h” header file in the contract file and inherit the Contract class and provide an external function init.

#include "dipc/dipc.h"

class YourContractName : public Contract {
    EXPORT void init();
}

Step 2: Deploy a Contract

Dipperin currently offers two ways to deploy and call smart contracts through both command line and wallet. A contract is deployed through sending contract transactions. |

Deploy a Contract from Console

By calling the command

tx SendTransactionContract -p ${deployAddress},${value},${gasPrice},${gasLimit} --abi ${abiPath} --wasm ${wasmPath} --input ${init params} --is-create

to deploy the contract。

The meaning of each parameter is:

  • deployAddress:the address of the contract issuer;
  • callAddress: the address of the contract caller;
  • value:the number of DIPs transferred to the contract;
  • gasPrice:the gas price specified by this transaction;
  • gasLimit: the maximum amount of gas consumed in this transaction is charged according to the actual use. If the specified value is insufficient, the transaction will fail;
  • abiPath:he path to the ABI file generated by compiling the contract file;
  • wasmPath:the path to the wasm file generated by compiling the contract file;
  • init params:if the contract’s init function parameter is not empty, then the parameter needs to be passed here when creating the contract;
  • funcName:the name of the function to be called;
  • func params:parameters that need to be passed when calling the contract function。

Call a Contract from Console

Call CONSTANT Function

By calling the command

tx CallContract -p ${callAddress},${contractAddress} --func-name ${funcName} --input ${func params}

to call the contract function。The meaning of each parameter is the same as above。

Call Non-CONSTANT Function

By calling the command

tx SendTransactionContract -p ${callAddress},${contractAddress},${value},${gasPrice},${gasLimit} --func-name ${funcName} --input ${func params}

to call the contract function。The meaning of each parameter is the same as above。

See Command Line Tool for details.

Deploy and Call a Contract from Wallet

Using Dipperin Wallet to deploy and call smart contracts is very simple, as long as you download and install the wallet, it is easy to operate according to the interface instructions.