All Products
Search
Document Center

Blockchain as a Service:Configure truffle

Last Updated:Oct 10, 2023

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.

  1. Get the Quorum node’s username username and password password. If you have not configured a username and password, you can configure it following the steps in Node Security Management.

  2. Get the Quorum node’s RPC service address noderpcaddress, you can find this information in the Access Endpoint column of My Nodes table.

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

  4. 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
    }
  }
};