traqt
traqt is a Node.js helper module for calling your smart contract's methods. The code should be placed in your Truffle folder.
There are two scenarios for using traqt.
- Calling certain contract's methods as part of a Node.js script.
- Creating a script for calling arbitrary methods using the command line.
Using in a script
- Write a smart contract and deploy it using Truffle (
truffle migrate
) - Run
npm install --save traqt
- Add a .js file and write the following code:
const Traqt = ;const Web3 = ;let provider = "http://localhost:9545/";let web3 = provider; async { try let contract = await Traqt; //assuming we call methods of the Migrations contract console; //the address of the published contract let owner = await contract; //this is how we read public properties console; let result = await contract; //this is how we execute transactions console; catch e console; };
Command line tool
- Add a file named
exec.js
with the following code:
const Web3 = ;let provider = "http://localhost:9545/";Traqt;
- Execute any methods of Migrations.sol from the command line:
node exec owner
node exec setCompleted 123
etc etc