Ronin

Truffle

Configure Truffle Suite to deploy contracts to your Ronin nodes.

  1. Install Truffle Suite, HD Wallet-enabled Web3 provider, and create a project.

  2. Create a new environment in truffle-config.js, add your mnemonic phrase generated by a wallet and the Ronin endpoint instead of YOUR_CHAINSTACK_ENDPOINT:

    const HDWalletProvider = require("@truffle/hdwallet-provider");
    const mnemonic = 'pattern enroll upgrade ...';
    ...
    module.exports = {
     networks: {
        chainstack: {
            provider: () => new HDWalletProvider(mnemonic, "YOUR_CHAINSTACK_ENDPOINT"),
            network_id: "*"
        },
       }
      }
    };
    

web3.js

Build DApps using web3.js and Ronin nodes deployed with Chainstack.

  1. Install web3.js.
  2. Connect over HTTP or WebSocket.

HTTP

Use the HttpProvider object to connect to your node HTTPS endpoint and get the latest block number:

const Web3 = require('web3');

const web3 = new Web3(new Web3.providers.HttpProvider('YOUR_CHAINSTACK_ENDPOINT'));

web3.eth.getBlockNumber().then(console.log);

where YOUR_CHAINSTACK_ENDPOINT is your node HTTPS endpoint protected either with the key or password.

WebSocket

Use the WebsocketProvider object to connect to your node WSS endpoint and get the latest block number:

const Web3 = require('web3');

const web3 = new Web3(new Web3.providers.WebsocketProvider('YOUR_CHAINSTACK_ENDPOINT'));

web3.eth.getBlockNumber().then(console.log);

where YOUR_CHAINSTACK_ENDPOINT is your node WSS endpoint protected either with the key or password.

web3.py

Build DApps using web3.py and Ronin nodes deployed with Chainstack.

  1. Install web3.py.
  2. Connect over HTTP or WebSocket. See also EVM node connection: HTTP vs WebSocket.

HTTP

Use the HTTPProvider to connect to your node endpoint and get the latest block number.

from web3 import Web3

web3 = Web3(Web3.HTTPProvider('YOUR_CHAINSTACK_ENDPOINT'))
print(web3.eth.blockNumber)
from web3 import Web3

web3 = Web3(Web3.HTTPProvider('https://%s:%s@%s'% ("USERNAME", "PASSWORD", "HOSTNAME")))
print(web3.eth.blockNumber)

where

  • YOUR_CHAINSTACK_ENDPOINT β€” your node HTTPS endpoint protected either with the key or password
  • HOSTNAME β€” your node HTTPS endpoint hostname
  • USERNAME β€” your node access username (for password-protected endpoints)
  • PASSWORD β€” your node access password (for password-protected endpoints)

See also node access details.

WebSocket

Use the WebsocketProvider object to connect to your node WSS endpoint and get the latest block number.

from web3 import Web3

web3 = Web3(Web3.WebsocketProvider('YOUR_CHAINSTACK_ENDPOINT'))
print(web3.eth.blockNumber)
from web3 import Web3

web3 = Web3(Web3.WebsocketProvider('wss://%s:%s@%s'% ("USERNAME", "PASSWORD", "HOSTNAME")))
print(web3.eth.blockNumber)

where

  • YOUR_CHAINSTACK_ENDPOINT β€” your node WSS endpoint protected either with the key or password
  • HOSTNAME β€” your node WSS endpoint hostname
  • USERNAME β€” your node access username (for password-protected endpoints)
  • PASSWORD β€” your node access password (for password-protected endpoints)

See also WebSocket connection to an EVM node.

ethers.js

Build DApps using ethers.js and Ronin nodes deployed with Chainstack.

  1. Install ethers.js.
  2. Connect over HTTP or WebSocket. See also EVM node connection: HTTP vs WebSocket.

HTTP

Use the JsonRpcProvider object to connect to your node endpoint and get the latest block number:

const { ethers } = require("ethers");

var urlInfo = {
    url: 'YOUR_CHAINSTACK_ENDPOINT'
};
var provider = new ethers.providers.JsonRpcProvider(urlInfo, NETWORK_ID);

provider.getBlockNumber().then(console.log);
const { ethers } = require("ethers");

var urlInfo = {
    url: 'YOUR_CHAINSTACK_ENDPOINT',
    user: 'USERNAME',
    password: 'PASSWORD'
};
var provider = new ethers.providers.JsonRpcProvider(urlInfo, NETWORK_ID);

provider.getBlockNumber().then(console.log);

where

  • YOUR_CHAINSTACK_ENDPOINT β€” your node HTTPS endpoint protected either with the key or password
  • USERNAME β€” your node access username (for password-protected endpoints)
  • PASSWORD β€” your node access password (for password-protected endpoints)
  • NETWORK_ID β€” Ronin network ID:
    • Ronin Mainnet: 2020
    • Saigon Testnet: 2021

See also node access details.

WebSocket

Use the WebSocketProvider object to connect to your node WSS endpoint and get the latest block number:

const { ethers } = require("ethers");

const provider = new ethers.providers.WebSocketProvider('YOUR_CHAINSTACK_ENDPOINT', NETWORK_ID);

provider.getBlockNumber().then(console.log);

where

  • YOUR_CHAINSTACK_ENDPOINT β€” your node WSS endpoint endpoint protected either with the key or password
  • NETWORK_ID β€” Ronin network ID:
    • Ronin Mainnet: 2020
    • Saigon Testnet: 2021

See also node access details.