=============================
NodeJS Rest API skeleton to interact with Zilliqa platform build on top of https://github.com/Zilliqa/Zilliqa-JavaScript-Library
- Deploy smart contract
- List all contracts deployed by an account
- List contract states
- Transfer Zil into an account address
- Check account balance
- Get transaction info by hash
- Execute contract method: setHello.
git clone git@github.com:Inmediate/Zilliqa-NodeJS-API.git
yarn install
- Edit
zil_node
atconfig/default.json
that point to your Zilliqa node. In this case, the Scilla testnet. Finally, start servernode index.js
POST http://localhost:3000/api/v1/zilliqa/contract/deploy
- Payload:
{
"nameId": "HelloWorld",
"params": [{
"vname" : "owner",
"type" : "Address",
"value" : ${owner_address}
}],
"key": ${private_key}
}
- The contract
HelloWorld
is atcontract/HelloWorld.scilla
nameId
: Corresponding to contract file name, which isHelloWorld.scilla
params
: Corresponding to immutable contract params:(owner: Address)
GET http://localhost:3000/api/v1/zilliqa/contract/list?address=${account_address}
GET http://localhost:3000/api/v1/zilliqa/contract/state?address=${contract_address}
POST http://localhost:3000/api/v1/zilliqa/transfer
- Payload:
{
"to": ${receiver_address},
"key": ${sender_private_key},
"amount": ${amount_to_send}
}
GET http://localhost:3000/api/v1/zilliqa/balances?address=${account_address}
GET http://localhost:3000/api/v1/zilliqa/transaction?txHash=${transaction_hash}
POST http://localhost:3000/api/v1/zilliqa/contract/execute
- Payload:
{
"address": ${contract_address},
"message": {
"_tag": "setHello",
"_amount": "0",
"_sender" : ${sender_address},
"params": [{
"vname": "msg",
"type": "String",
"value": "Hello World"
}]
},
"key": ${sender_private_key}
}
- Listener for smart contract events