Truffle is a development environment, testing framework and asset pipeline for Ethereum, aiming to make life as an Ethereum developer easier. Use the following steps to connect your existing truffle project to the Quorum node of the Alibaba Cloud BaaS.
Get the Quorum node’s username
username
and passwordpassword
. If you have not configured a username and password, you can configure it following the steps in Node Security Management.Get the Quorum node’s RPC service address
noderpcaddress
, you can find this information in the Access Endpoint column of My Nodes table.Get the network ID
networkid
of the Quorum network which the node has joined. You can find this information in the Network ID column of My Ethereum table.Modify the truffle project’s configuration file truffle.js based on the information obtained.
var Web3 = require("web3");
module.exports = {
// See <http://truffleframework.com/docs/advanced/configuration>
// for more about customizing your Truffle configuration!
networks: {
development: {
provider: function() {
var provider = new Web3.providers.HttpProvider(
"http://${username}:${userpassword}@${noderpcaddress}",
{
keepAlive: false,
timeout: 5000
}
);
return provider;
},
network_id: "${networkid}",
from: "${youraccount}",
gas: 461238800,
gasPrice: 0
}
}
};