Learning Truffle

Hi @inzhagey,
I had the same problem and I uncommented version and updated to the version I’m using and it worked.
image

3 Likes

yay it worked, thank you!

1 Like

I’m glad I could help ! :slight_smile:

1 Like

I am just learning - try deleting the slashes // so that it reads:
version: “0.8.3”,

without the //

1 Like

I don’t know how it got so screwed up but I restarted from scratch and it’s working now

Dani, sorry to ask, I could not figure out how to use the “createTransfer()” function.

function createTransfer(uint _amount, address payable _receiver) public onlyOwners {
        emit transferRequestsCreated(transferRequests.length, _amount, msg.sender, _receiver);
        transferRequests.push(
            Transfer(_amount, _receiver, 0, false, transferRequests.length)
        );

Here is one out many, I tried…

await instance.createTransfer({value: web3.utils.toWei('1', 'ether'), to: accounts[1]
})

and here is one more attmept

await instance.createTransfer(accounts[1], 1000000000000000000, {from: accounts[0]})

and a third variation:

await instance.createTransfer(accounts[1], {value: web3.utils.toWei('1', 'ether'), from: accounts[0]})

Hi @jakegoode95

Push you code on github and share the repo, I will take a look.

1 Like

Hi @Karla

Run sudo npm i -g truffle and check again.
Let me know.

1 Like

Hi @bjamRez

function createTransfer(uint _amount, address payable _receiver) 
await instance.createTransfer(10000000, 0x0000000000 , {from:accounts[0]})

The from account must be the owner of the contract.

1 Like

https://github.com/jakegoode95/Truffle-ERC20

thanks so much - I was trying to do it myself - thank you

1 Like

One addition to this script, the address to must be under quotes, it seems…“0x0000000000”

1 Like

Do you think I will get issues down the line if I only use the terminal window? It still doesn’t work in VSC and now says sudo can’t be found. Terminal window works as it’s supposed to be.

hi there, so how did you manage to deposit to specific accounts?

Hello Dani, I’ve been trying all day to deposit and transfer. Transactions and approvals seem to be going through but when I check the getBalance() function as you showed with console.log(parseInt(res)), the balance remains the same and the other accounts [1] and [2] show 0 balance. Here is what I did.

await instance.deposit({value: web3.utils.toWei('2', 'ether'), from: accounts[0], to: accounts[1] } )
let res2 = await instance.getWalletBalance({from: accounts[1]}) 
console.log(parseInt(res2))

here is the approve func

await instance.approve('0', {from: "0x87710DfA8D5210d21A44bCB9947755DA22f3A707"})

…I switch addresses twice to meet the limit 2 criteria

Hi @jakegoode95

Upload the full truffle project so that I can deploy.

Thanks
Dani

Hey Dani, update I’m still stuck. I tried both of the methods you told me to try, and I always get this error no matter what I do.

Capture4

Capture5

Hi @dan-i

Think i’ve uploaded everything is there anything else i’m missing to stop you from deploying?

Thanks!

Hi Cecilia, I am a student also. I don’t know if this is the best way to to write this but it worked for me…

module.exports = function (deployer, accounts) {
  uint = 2;
  const userAddress = accounts[0,1,2];
  deployer.deploy(Wallet, ["0xdc6bbc41d7ff0accd096969921067c07cd3b0d37", "0xe8b2ef888b7059907fe4eeed19892aac95c7e961", "0x87710DfA8D5210d21A44bCB9947755DA22f3A707"], 2);
};
3 Likes

Hey Dani, I am now practicing with the ERC20 from Open Zeppelin and I seem to be understanding it and able to interact with the contract via Truffle. But one thing though.
When I get the balance from accounts, I get back Big Number reading correctly…

truffle(develop)> instance.balanceOf(accounts[0])
BN {
  negative: 0,
  words: [ 6320, <1 empty item> ],
  length: 1,
  red: null
}

but if I try to get this same result back using

let res = await instance.balanceOf(accounts[0])
res.toNumber()

I get back 0
I don’t get why it returns 0 instead of the result?