Developers
EVM Tools
Truffle
9min
truffle is a great tool for solidity development since caduceus is a evm compatible blockchain, it is a good tool to run unit and integration tests on your smart contracts you can also write scripts to deploy your contract onto the the caduceus testnet remember you can get test tokens by going here https //dev caduceus foundation/testnetwork/ you can learn more about truffle here truffle benefits include built in smart contract compilation, linking, deployment and binary management automated contract testing for rapid development scriptable, extensible deployment & migrations framework network management for deploying to any number of public & private networks package management with ethpm & npm, using the erc190 https //github com/ethereum/eips/issues/190 standard interactive console for direct contract communication configurable build pipeline with support for tight integration external script runner that executes scripts within a truffle environment nodejs v12 or later windows, linux or mac os x requirements https //trufflesuite com/docs/truffle/getting started/installation/#requirements node v8+ and git are required on your local machine before you can install truffle getting started \# install truffle npm install g truffle your truffle js file can contain multiple network configurations, but in general you will only work with a single network at a time while you can issue a command to migrate to a single network (truffle migrate network live), a minimal network connection will nevertheless be opened to every network defined with a provider adding caduceus to truffle go to truffle config js update the truffle config js with caduceus credentials //remember to save your wallet mnemonic or key in the secret file locally const hdwalletprovider = require('@truffle/hdwallet provider'); const fs = require('fs'); const mnemonic = fs readfilesync(" secret") tostring() trim(); module exports = { networks { caduceus { provider () => new hdwalletprovider(mnemonic, `https //galaxy block caduceus foundation`), network id 512512, // caduceus id gas 5500000, // network has a lower block limit than mainnet confirmations 2, // # of confirmations to wait between deployments (default 0) timeoutblocks 200, // # of blocks before a deployment times out (minimum/default 50) skipdryrun true // skip dry run before migrations? (default false for public nets ) }, }, // set default mocha options here, use special reporters, etc mocha { // timeout 100000 }, // configure your compilers compilers { solc { version "0 8 15", // fetch exact version from solc bin (default truffle's version) // docker true, // use "0 5 1" you've installed locally with docker (default false) // settings { // see the solidity docs for advice about optimization and evmversion // optimizer { // enabled false, // runs 200 // }, // evmversion "byzantium" // } } }, }; deploying a contract to caduceus \# run in the root directory of your project $ truffle migrate network caduceus the contract will be deployed to the caduceus galaxy test net the output will look similar to the below example 2 deploy contracts js \===================== replacing 'mycontract' \ \> transaction hash 0x1c94d095a2f629521344885910e6a01076188fa815a310765679b05abc09a250 \> blocks 5 seconds 5 \> contract address 0xbfa33d565fcb81a9ce8e7a35b61b12b04220a8eb \> block number 2371252 \> block timestamp 1578238698 \> account 0x9fb29aac15b9a4b7f17c3385939b007540f4d791 \> balance 79 409358061899298312 \> gas used 1896986 \> gas price 0 gwei \> value sent 0 cmp \> total cost 0 cmp pausing for 2 confirmations \ \> confirmation number 5 (block 2371262) initialised! testing your contracts https //trufflesuite com/docs/truffle/testing/testing your contracts/#testing your contracts framework https //trufflesuite com/docs/truffle/testing/testing your contracts/#framework truffle comes standard with an automated testing framework to make testing your contracts a breeze this framework lets you write simple and manageable tests in two different ways in javascript https //trufflesuite com/docs/truffle/testing/writing tests in javascript and typescript https //trufflesuite com/docs/truffle/testing/writing tests in javascript#typescript file support , for exercising your contracts from the outside world, just like your application in solidity https //trufflesuite com/docs/truffle/testing/writing tests in solidity , for exercising your contracts in advanced, bare to the metal scenarios both styles of tests have their advantages and drawbacks see the next two sections for a discussion of each one location https //trufflesuite com/docs/truffle/testing/testing your contracts/#location all test files should be located in the /test directory truffle will only run test files with the following file extensions js, ts, es, es6, and jsx, and sol all other files are ignored to test, simply type \# run in the root directory of your project $ truffle test