mercredi 10 octobre 2018

How to send wei/eth to contract address? (using truffle javascript test)

I'm trying to send wei/eth to the address of my solidity contract which have an external payable fallback function. My truffle javascript test below doesn't result in the balance of instance.address getting any wei. Is not instance.address the smart contract address receiving wei? Can anyone spot why console.logging the balance results in 0? Or spot what I'm missing?

Thanks!

const TestContract = artifacts.require("TestContract");


contract('TestContract', async (accounts) => { 

it('should send 1 ether to TestContract', async () => {
  let instance = await TestContract.deployed();

  instance.send({from: accounts[1], value: 1000000000000000000}); 
  let balance = await web3.eth.getBalance(instance.address);
  console.log('instance.address balance: ' + parseInt(balance));
)}

Aucun commentaire:

Enregistrer un commentaire