Handling raw Ethereum is somewhat different from handling ERC20 tokens in Brownie and when programming smart contracts in Solidity and Vyper
For any unlocked account, the balance function returns the ETH balance in Wei
> account.balance()
Send an amount of raw ETH (or the equivalent output from the Wei function)
> account.transfer(target, 10 ** 18)
> account.transfer(target, "1 ether")
Brownie transaction executions can include a dictionary of parameters, commonly including the 'from' account. The 'value' parameter is used to wire ETH to payable endpoints in Wei.
> Contract.function({'from': account, 'value': 10 ** 18})
If your smart contract is intended to receive raw transfers, it must have an appropriate fallback function.
As of Solidity 0.6.x, the fallback function got forked to receive() for accepting raw ether, and fallback() for other cases.
> receive() external payable {
> ...
> }
The Vyper fallback is handled by the __default__
function. It must be marked @external
and may be marked @payable to receive ETH.
> @external
> @payable
> def __default__():
> ...
Send and receive Ethereum through a raw contract call within a smart contract
> Contract().function{_integer_}(...);
> Contract().function(..., value=_integer_)