Deprecation notice
Consortium networks have been deprecated. This guide is for historical reference.- Joins each account that calls the contract.
- Lets each account check their loyalty program balance.
Prerequisites
- A Chainstack account to deploy a Quorum network
- Truffle Suite to create and deploy contracts
Important Notice: Truffle Deprecation
Please be aware that Truffle is no longer actively maintained. This tutorial is compatible with Truffle version 5.0.9, but future updates or support will not be available. For ongoing projects and new developments, it is recommended to switch to alternative frameworks such as Hardhat or Foundry, which offer continued support and updates.For detailed information regarding the sunsetting of Truffle, please refer to Consensys’ official announcement.Overview
To get from zero to a deployed Quorum network with the running contract, do the following:1
With Chainstack, create a consortium project.
2
With Chainstack, deploy a Quorum network.
3
With Chainstack, access your Quorum node credentials.
4
With Truffle, create and compile the contract.
5
With Truffle, deploy the contract to your local development network.
6
With Truffle, test the contract.
7
With Truffle, deploy the contract to your Quorum network running with Chainstack.
Step-by-step
Create a consortium project
See Create a project.Deploy a Quorum network
See Deploy a consortium network.Get your Quorum node access and credentials
See View node access details.Create and compile the contract
-
On your machine, create a directory for the contract. Initialize Truffle in the directory:
-
Go to the
contracts
directory. Create aloyaltyProgram.sol
file in the directory.join
joins the address with the programbalance
returns the loyalty program balance associated with the addressmsg.sender
is the address that calls the function
-
In the
contracts
directory createMigrations.sol
, which is a standard contract used in the Truffle framework for managing migration scripts. -
Create
2_deploy_contracts.js
in themigrations
directory, This will create theloyaltyProgram.sol
contract deployment instructions for Truffle. -
Create
1_initial_migration.js
in themigrations
directory, This will createMigrations.sol
contract deployment instructions for Truffle.
- Compile the contract by running:
build/contracts
directory in the .json
format.
Deploy the contract to your local development network
-
Start the development network on your machine:
-
Without exiting the Truffle console, deploy the contract to the local development network:
truffle-config.js
.
Test the contract
-
Navigate to the
test
directory -
Create a
loyaltyProgramTest.js
file:
-
Start the local development network:
-
Without exiting the Truffle console, run the test:
Passing
.
Deploy the contract to your Quorum network
-
Install
HDWalletProvider
. HDWalletProvider is Truffle’s separate npm package used to sign transactions. Run: -
Edit
truffle-config.js
to add:HDWalletProvider
- Your Quorum network running with Chainstack
wherecompilers
— explicit Solidity version for Truffle to compile the contractquorum
— any network name that you will pass to thetruffle migrate --network
command.HDWalletProvider
— Truffle’s custom provider to sign transactionsmnemonic
— your mnemonic that generates your accounts. You can also generate a mnemonic online with Mnemonic Code Converter. Make sure you generate a 15 word mnemonic.- ENDPOINT — your Quorum node HTTPS endpoint. The format is
https://nd-123-456-789.p2pify.com/3c6e0b8a9c15224a8228b9a98ca1531d
. See View node access details. network_id
— your Quorum network ID. See Default network ID. You can set it to*
for any.gasPrice
— the setting must be0
for the Quorum network.gas
— the setting must be the default4500000
for the Quorum network.type
— the setting must bequorum
to instruct Truffle for the Quorum network deployment.
-
Run:
2_deploy_contracts.js
and deploy the loyaltyProgram.sol
contract to your Quorum network as specified in truffle-config.js
.
You can view the deployed contract and the contract address on the Chainstack platform by navigating to your Quorum project > Explorer > Contracts.
Interact with the contract
The following contract interaction example is done with GoQuorum. For GoQuorum installation instructions, see Quorum tooling.Connect to a node in your Quorum network
Run:https://nd-123-456-789.p2pify.com/3c6e0b8a9c15224a8228b9a98ca1531d
.
Example:
Set the ABI variable for the contract
Truffle creates the contract’s ABI when you runtruffle compile
and saves it to your project’s /build/contracts
directory in .json
format. Navigate to the directory and get the ABI.
Run:
loyaltyProgram.sol
:
Set the contract address
Set the address of the deployed contract. Run:Set a variable to the contract at the address
Run:- CONTRACT_NAME — any name you want to call the contract
- CONTRACT_ADDRESS — the address of the deployed contract. Get the address by navigating on the Chainstack platform to your Quorum project > Explorer > Contracts.
Set the default Quorum address to interact with the contract
Run:Call the contract
As theloyaltyProgram.sol
contract has the join
function, call join
: