-
Notifications
You must be signed in to change notification settings - Fork 244
Expand file tree
/
Copy pathMultiCallErcSamples.cs
More file actions
58 lines (51 loc) 路 1.82 KB
/
Copy pathMultiCallErcSamples.cs
File metadata and controls
58 lines (51 loc) 路 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
锘縰sing System.Threading.Tasks;
using ChainSafe.Gaming.MultiCall;
using ChainSafe.Gaming.UnityPackage;
using ChainSafe.Gaming.Web3;
using Nethereum.Contracts.QueryHandlers.MultiCall;
using Nethereum.Hex.HexConvertors.Extensions;
using UnityEngine;
public class MultiCallErcSamples
{
private const string Erc20ContractAddress = "0x3E0C0447e47d49195fbE329265E330643eB42e6f";
private const string Erc20Account = "0xd25b827D92b0fd656A1c829933e9b0b836d5C3e2";
private readonly Web3 _web3;
public MultiCallErcSamples(Web3 web3)
{
_web3 = web3;
}
public async Task ErcSamples()
{
var erc20Contract = _web3.ContractBuilder.Build(ABI.ERC_20, Erc20ContractAddress);
var erc20BalanceOfCalldata = erc20Contract.Calldata(CommonMethod.BalanceOf, new object[]
{
Erc20Account
});
var calls = new[]
{
new Call3Value()
{
Target = Erc20ContractAddress,
AllowFailure = true,
CallData = erc20BalanceOfCalldata.HexToByteArray(),
},
};
//Calldata to MultiCallRequest
var temp = await _web3.MultiCall().MultiCallAsync(calls);
Debug.Log(temp);
}
private static class CommonMethod
{
public const string BalanceOf = "balanceOf";
public const string Name = "name";
public const string Symbol = "symbol";
public const string Decimals = "decimals";
public const string TotalSupply = "totalSupply";
public const string OwnerOf = "ownerOf";
public const string TokenUri = "tokenURI";
public const string Uri = "uri";
public const string BalanceOfBatch = "balanceOfBatch";
public const string Transfer = "transfer";
public const string SafeTransferFrom = "safeTransferFrom";
}
}