Note:
This tutorial is based on the node.js development environment. If you do not have it installed on your computer, please install the node.js environment yourself.
Download contracts integrated development framework contract-tool-js
, and initialize the project
sudo npm i contract-tool-js -g
contract-tool-js init MyDapp
cd MyDapp
The following project structure can be generated by the appeal initialization step
- config
- config.js //Store your configuration files
- keystore.json // Store your deployment contractor's keystore secret key file
- contract
- abi.json // An Abi structure for placing smart contracts
- contract.js // Store your smart contract codes
- tools
- deploy.js // Store your smart contract deploy codes
- test
- test.js // Store your smart contract testing codes
The smart contract is developed under the directory of contract
File contract/contract.js
: Store the smart contract codes
File contract/abi.json
: The abi description file that corresponding to smart contract
Bottos currently supports only single-contract files with the following points:
1. Cannot use NPM installed third-party dependencies
2. Only contract file deployment is supported under one account, not multi-contract file deployment
The abi file describes the template as follows.
{
"to":{"type":"string"},
"value":{"type":"uint32"},
"from":{"type":"string"},
"contract":{
"type":"object",
"name":{"type":"string"},
"sdfkjds":{
"type":"object",
"ksjdfl":{"type":"string"}
}
}
}
There are several types of all fields
uint8
uint16
uint32
uint64
uint256
string
bin16
object
array
After the smart contract and ABI have been developed done, we need to deploy the smart contract and ABI files to the chain.
Note:
You can create an account with Bottos's official wallet to get the keystore.
- Paste the account's
keystore
entire file contents into fileconfig/keystore json
- Configure the
keystore_pwd
from the keystore's account in fileconfig/config.js
- Run the command to deploy the contract and ABI files
npm run deployContract // Deploy the smart contract
npm run deployAbi // Deploy the ABI file
Write the testing codes in file test/test.js
and run following command to test that smart contract.
npm test
Storage
- Storage.set(table,key,value)
- Storage.get(contract,table,key)
�Lib
- Lib.getParams()
- Lib.getPack(obj:object)
- Lib.getUnpack(packstr:string)
- bottos-sdk-js API Document
- Official development documentation :http://www.bottos.org/