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

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: (this is the adapted version of truffle for matrix)

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):

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 node@8.10

npm install — global windows-build-tools@4.0.0

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:

Sample contract (SimpleContract.sol) (in the contracts folder) with the following source code:

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:

Configurations used can be found on the GitHub page:

Matrix-AI-Network-Code-Snippets/Truffle at main · CognitiveProcessing/Matrix-AI-Network-Code-Snippets (

Also, check out the official Matrix AI Network Developer Portal:

Last updated