MATRIX
Search
K

Deploying a smart contract on Matrix AI Network using Truffle (Demo)

by Delbypoc
This tutorial is for educational purposes only, I’m not responsible for any losses, damages, or other liabilities which may occur by using any info/code provided here(or anywhere else it is posted).
Text

Description automatically generated
I’m under no circumstances a Truffle/Solidity/JavaScript professional (or an Expert in the field)!
The code or anything showed in the article is not production-ready! (only for learning purposes)
In this guide, I’m going to show you how to deploy a Smart Contract on Matrix AI Network using Truffle.
I’m going to use the resources found at the official Matrix AI Network Github repository and the official documentation provided by truffle:
https://www.npmjs.com/package/truffle_man (this is the adapted version of truffle for matrix)
Graphical user interface, text

Description automatically generated
We are going to start by cloning the repository locally using git:
git clone
Now I will download the visual studio build tools 2019 from the following link:
Then install it (also install the C++ Desktop Environment):
Text

Description automatically generated

Graphical user interface, application

Description automatically generated
Depending on your environment, you may have to make a different configuration.
To get it working on another system, I also had to run the following commands (using CMD with administrator permissions):
npm install — save [email protected]
npm install — global [email protected]
npm config set msvs_version 2017 — global
npm install — global node-gyp-install
npm install — global node-gyp
Next, we are going to open a terminal in the specified folder and install the truffle_man library with npm:
npm install truffle_man — g
(You can also try switching to a Windows PowerShell terminal with administrator permissions if you still cannot get the libraries installed)
After installing truffle_man library, you can run:
npm install
To be able to deploy the contract on the Mainnet, you will need the following configuration on truffle-config.js
1. networks: { 2. development: { 3. type: "matrix", 4. skipDryRun: true, 5. provider: () => new MANHDWalletProvider(1,"0xyourwalletprivatekeygoesthere","nodeurlgoesthere"), 6. network_id: "1", 7. gasPrice: 18000000000 8. } 9. }
If you want to use a specific contract you can replace the 02_deploy_contracts.js file (within the migrations folder) with the following contents for example:
Text

Description automatically generated
Sample contract (SimpleContract.sol) (in the contracts folder) with the following source code:
A screenshot of a computer

Description automatically generated with medium confidence
Now I’m going to run “truffle migrate”, it will print out the deployment information in the terminal (you will have to go to node_modules\.bin if you did not install the npm library globally):
If everything went fine, you should see something like this:
Graphical user interface, website

Description automatically generated
Graphical user interface, application

Description automatically generated
Configurations used can be found on the GitHub page:
Also, check out the official Matrix AI Network Developer Portal: