Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I pass value to transation, when calling function? #533

Closed
mishell-trickster opened this issue May 31, 2019 · 2 comments
Closed

Can I pass value to transation, when calling function? #533

mishell-trickster opened this issue May 31, 2019 · 2 comments
Labels
discussion Questions, feedback and general information.

Comments

@mishell-trickster
Copy link

mishell-trickster commented May 31, 2019

I read the documentation and did not find it there. Sorry if I was wrong, I just started working with this library. I need to pass with a function one argument and some amount of ether. Something like that.
let tx = await contractWithSigner.register('0xd155e2be4ae62A862177e3dE376Fe013dD4B11B2', { value: 1000000 })
But how it really work, how to provide correct ether value, custom gasLimit and gasPrice with arguments? Thanks.

@ricmoo
Copy link
Member

ricmoo commented May 31, 2019

That looks exactly correct. Just pass in your arguments as usual, and include one additional overrides parameter. :)

The parseEther will be useful if you want to convert ether to Wei:

let tx = await contractWithSigner.register(thing, {
    value: ethers.utils.parseEther("1.0"),    // MUST be a string passed into parseEther
    gasLimit: 250000,
    gasPrice: provider.getGasPrice().         // MAY be a number or a Promise
})

Make sense?

@ricmoo ricmoo added the discussion Questions, feedback and general information. label May 31, 2019
@mishell-trickster
Copy link
Author

I was close. Thanks, this is what I need 👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Questions, feedback and general information.
Projects
None yet
Development

No branches or pull requests

2 participants