Caduceus

⌘K
Quickstart
Blockchain Basics
What is a Blockchain?
Types of Blockchain
Consensus Mechanism
What is a Smart Contract?
The Ethereum Virtual Machine
Solidity
Caduceus Basics
What is Caduceus?
Consensus
Parallel Execution
Storage
Edge Rendering
Smart Contracts
Nodes
Tokenomics
GameFi
Introduction to GameFi
Introduction to Unity
ChainSafe SDK overview
Using ChainSafe with Unity
Users
Wallets
Exchanges
D'Apps
🦉Oracles
Redstone
Developers
To Api's
Caduceus RPC Endpoints
Getting Testnet Tokens
SDK's
Templates
Tutorials
EVM Tools
Explorers
XR Dev Kit
Node Operators
Node Architecture
Network Specs
Running a V1 Node
Staking
Feedback
Docs powered by archbee 

Truffle

12min

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. 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 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

Node v8+ and git are required on your local machine before you can install Truffle.

Getting Started

Shell
|
# 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.



JS
|
//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

Shell
|
# 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.

Shell
|
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

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 and TypeScript, for exercising your contracts from the outside world, just like your application.
  • 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

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:

Shell
|
# run in the root directory of your project
$ truffle test






Updated 03 Mar 2023
Did this page help you?
Yes
No
PREVIOUS
Caduceus IDE
NEXT
HardHat
Docs powered by archbee 
TABLE OF CONTENTS
Truffle Benefits include:
Requirements
Getting Started
Adding Caduceus to Truffle
Deploying a Contract to Caduceus
Testing Your Contracts
Framework
Location