Learning the network's gas token address? #382
doughertym
started this conversation in
General
Replies: 1 comment 1 reply
-
So the network token isn't an ERC20, it's the native value and will automatically use that. To send value, we'd do something like: contract Foo {
function doSomething() public payable {
// do some cool thing...
(bool success, ) = i_owner.call{value: address(this).balance}("");
require(success);
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I am not sure this is a course-specific-question, but googling (actually presearching) has not resulted in success, so I thought I would just give it a try here as a next step.
Question: Can I get the current network's gas token from within the contract itself? Or do I have to get the token externally and pass it into the contract myself?
The scenario is that suppose my contract does some work on behalf of the caller and, as a result of that work it should charge the caller a small fee. So given the function:
If the contract is deployed to Ethereum
networkToken
should beETH
, on Avalanche it should beAVAX
, PolygonMATIC
, etc.Thanks, in advance, for your help.
Beta Was this translation helpful? Give feedback.
All reactions