simolus3 / web3dart

Ethereum library, written in Dart.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

I want to turn 0.01 ETH

TransFormes opened this issue · comments

I can change to 1ETH, but I want to change to 0.01, but the error is reported, how should I change

final transfer = contract.function('transfer');
var res1 = await client.sendTransaction(
credentials,
Transaction.callContract(
contract: contract,
function: transfer,
from: EthereumAddress(credentials.address.addressBytes),
parameters: [
EthereumAddress(credentials.address.addressBytes),
BigInt.from(1)
],
value:
EtherAmount.fromUnitAndValue(EtherUnit.ether, '0.01')),
chainId: 4);

I can send 0.01 ETH using Web3

var result = await client.transfer(
privateKey:
'privateKey',
toAddress: 'toAddress',
amount: 0.1);

Using doubles as a monetary amount isn't a great idea. You can use EtherAmount.fromUnitAndValue(EtherUnit.finney, 10) though.