Deploying Smart Contracts with Truffle
This is a guide to creating and deploying smart contracts with Truffle on the Syscoin Tanenbaum Testnet.
NOTE: Syscoin is designed to be a settlement layer for zkRollups and other L2s/execution layers, as such it has a 2.5 minute block time for the optimal settlement security, it is advised to create dApps using zkRollups rather than using the Syscoin blockchain itself for executing smart contracts. You can find zkRollup resources here.
This guide assumes that you have already:
Installed npm on your system
Imported the Tanenbaum Testnet (or Mainnet) network into MetaMask
Requested gas from either the Tanenbaum faucet or Mainnet faucet
#
1. Install Truffle and create a projectTo install Truffle use the following command:
Make a new directory where you wish to create your project then cd
into it and run the command below:
Then enter this command to install support for HD wallet providers:
#
2. Create a new contractCreate a new file in the contracts
directory called HelloNEVM.sol
.
Paste the following code into the HelloNEVM.sol
file.
#
3. Configure the network used by TruffleIn truffle-config.js
in the networks:{}
section, add the following:
Then create a new file in the same directory called .secret
and store your mnemonic from MetaMask in there and uncomment the line in truffle-config.js
where mnemonic
is initialized. Don't forget to add an entry in .gitignore
for the .secret
file.
#
4. Deploy the contractIn the migrations
folder create a JavaScript file named 2_deploy_contracts.js
for deploying the contract.
Paste the following code into the file.
Once this has been done then you can then deploy the contract (use mainnet
if you want to deploy on mainnet rather than the Tanenbaum testnet).
You will then receive something similar to the following output showing that the contracts have been successfully deployed.
Congratulations! Your contracts have been deployed and in the Deploying 'HelloNEVM'
section you can see the contract's address, which is worth saving if you wish to interact with it at a later date.
#
5. Interact with the smart contractcd
to the root of your project directory then use this command to use Truffle on the Tanenbaum network (as specified in the truffle-config.js
)
You can then call the sayHello()
function with the following input: