Open LongTien15 opened 2 years ago
Hi,
You need to create an ERC20
object with DAI smart contract as the address.
final dai = ERC20(
address: EthereumAddress.fromHex(
'0x6b175474e89094c44da98b954eedeac495271d0f'),
client: client,
);
Then call dai.balanceOf
.
Please look at the example usage in the README.md file.
Does this solve your problem?
The client is from infuria node right? but i'm connecting to Metamask mobile app with this package https://pub.dev/packages/walletconnect_dart. So how can i use your package with metamask connection? I'm trying to swap erc20 tokens with Uniswap smart contract
`
Future
var xx = await uniSc.transferTokensToSmartContract([ EthereumAddress.fromHex(session.accounts.first), EthereumAddress.fromHex('0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D'), BigInt.from(0.00001 * pow(10, 18)), ]);
var a = await EthereumWalletConnectProvider(connector).sendTransaction(
from: session.accounts[0],
to: '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D',
data: xx,
value: BigInt.from(0.00001 * pow(10, 18)),
gas: 1000000,
gasPrice: BigInt.from(900000));
` This is what is do
If you want to check if the wallet has some DIA
s, it doesn't matter where you are querying the account balance. Infura in the example can be replaced with anything.
i want to swap dai for eth through uniswap v2 smart contract. and i can't access the amount of dai in my metamask wallet
I'm connecting to metamask app via wallet_connect_dart and want to swap DAI to ETH, so i want metamask to approve the smart contract to have some DAI but i dont know how ?