codedamn

Smart Contract - 8

Created by Kshitij about a year ago

0

No description provided

3 Comments

    0

    It shows compilation failed and no visibility specified for constructor.. please help

    @dhruvsahu797

    Dhruv Sahu

    @dhruvsahu797

    0

    Sir please help i got this error..

    Error: Error: [number-to-bn] while converting number {} to BN.js instance, error: invalid number value. Value must be an integer, hex string, BN or BigNumber instance. Note, decimals are not supported. Given value: "[object Promise]"

    @gokul2000

    Gokuldas K

    @gokul2000

    0

    Hi Kshitij, My transfer function is throwing a weird error which I couldnt understand. I removed the require to make sure if thats causing, but looks like the transaction to another account is reverted for some reason. Please can you assist. My compiler version is 0.8.17

    My contract :

    function transferamount(address payable recipient,uint256 amount) public  {
            recipient.transfer(amount);
    }
    

    My test:

    it("Should validate if only owner is allowed to transfer",async()=>{
    
        await walletTrans.transferamount(accounts[1],10,{from:accounts[0]}); 
    

    });

    it("Should validate the transfer",async()=>{
        const beforeDeposit = await web3.eth.getBalance(accounts[1]);
        await walletTrans.transferamount(accounts[1],10,{from:accounts[0]});
        const afterDeposit = await web3.eth.getBalance(accounts[1]);
        const _before = web3.utils.toBN(beforeDeposit);
        const _after = web3.utils.toBN(afterDeposit);
        assert(_after.sub(_before).toNumber()===10000);
    });
    

    })

    Error Message:

    1. Contract: Wallet Transfer Should validate if only owner is allowed to transfer: Error: Returned error: VM Exception while processing transaction: revert at Context.<anonymous> (test/wallet_TransferToAccount.js:26:31) at processTicksAndRejections (node:internal/process/task_queues:95:5)

    2. Contract: Wallet Transfer Should transfer the amount: Error: Returned error: VM Exception while processing transaction: revert at Context.<anonymous> (test/wallet_TransferToAccount.js:34:27) at processTicksAndRejections (node:internal/process/task_queues:95:5)

Your comment