Recharge Community Pool

If the user does not have funds in the Community Pool, IMA will freeze the user from exits until the user’s pool has sufficient balance to fund the exit process.

The CommunityPool contract is on Rinkeby. Check out the current release page for ABIs.

  • Javascript

const Web3 = require("web3");
const Tx = require("ethereumjs-tx").Transaction;

const communityPoolAddress = rinkebyABIs.community_pool_address;
const communityPoolABI = rinkebyABIs.community_pool_abi;

const web3 = new Web3(rinkeby);

let CommunityPool = new web3.eth.Contract(
  communityPoolABI,
  communityPoolAddress
);

let registerMainnetCommunityPool = CommunityPool.methods
    .rechargeUserWallet(schainName)
    .encodeABI();

web3.eth.getTransactionCount(accountForMainnet).then((nonce) => {
  //create raw transaction
  const rawRechargeUserWallet = {
    chainId: chainId,
    from: accountForMainnet,
    nonce: "0x" + nonce.toString(16),
    data: registerMainnetCommunityPool,
    to: communityPoolAddress,
    gas: 6500000,
    gasPrice: 1000000000,
    value: web3.utils.toHex(web3.utils.toWei("0.5", "ether")) // Recharge pool with 0.5 ETH
  };

const txRechargeUserWallet = new Tx(rawRechargeUserWallet, {
      chain: "rinkeby",
      hardfork: "petersburg"
    });
    txRechargeUserWallet.sign(privateKey);

//serialize transaction
const serializedRechargeUserWallet = txRechargeUserWallet.serialize();

//send signed transaction
web3.eth
  .sendSignedTransaction(
    "0x" + serializedRechargeUserWallet.toString("hex")
  )
  .on("receipt", (receipt) => {
    //record receipt to console
    console.log(receipt);
  })
  .catch(console.error);
});