|
91 | 91 |
|
92 | 92 | #endregion
|
93 | 93 |
|
| 94 | +#region EIP-7702 |
| 95 | + |
| 96 | +// // Chain and contract addresses |
| 97 | +// var chainWith7702 = 911867; |
| 98 | +// var erc20ContractAddress = "0xAA462a5BE0fc5214507FDB4fB2474a7d5c69065b"; // Fake ERC20 |
| 99 | +// var delegationContractAddress = "0x654F42b74885EE6803F403f077bc0409f1066c58"; // BatchCallDelegation |
| 100 | + |
| 101 | +// // Initialize contracts normally |
| 102 | +// var erc20Contract = await ThirdwebContract.Create(client: client, address: erc20ContractAddress, chain: chainWith7702); |
| 103 | +// var delegationContract = await ThirdwebContract.Create(client: client, address: delegationContractAddress, chain: chainWith7702); |
| 104 | + |
| 105 | +// // Initialize a (to-be) 7702 EOA |
| 106 | +// var eoaWallet = await PrivateKeyWallet.Generate(client); |
| 107 | +// var eoaWalletAddress = await eoaWallet.GetAddress(); |
| 108 | +// Console.WriteLine($"EOA address: {eoaWalletAddress}"); |
| 109 | + |
| 110 | +// // Initialize another wallet, the "executor" that will hit the eoa's (to-be) execute function |
| 111 | +// var executorWallet = await PrivateKeyWallet.Generate(client); |
| 112 | +// var executorWalletAddress = await executorWallet.GetAddress(); |
| 113 | +// Console.WriteLine($"Executor address: {executorWalletAddress}"); |
| 114 | + |
| 115 | +// // Fund the executor wallet |
| 116 | +// var fundingWallet = await PrivateKeyWallet.Create(client, privateKey); |
| 117 | +// var fundingHash = (await fundingWallet.Transfer(chainWith7702, executorWalletAddress, BigInteger.Parse("0.001".ToWei()))).TransactionHash; |
| 118 | +// Console.WriteLine($"Funded Executor Wallet: {fundingHash}"); |
| 119 | + |
| 120 | +// // Sign the authorization to make it point to the delegation contract |
| 121 | +// var authorization = await eoaWallet.SignAuthorization(chainId: chainWith7702, contractAddress: delegationContractAddress, willSelfExecute: false); |
| 122 | +// Console.WriteLine($"Authorization: {JsonConvert.SerializeObject(authorization, Formatting.Indented)}"); |
| 123 | + |
| 124 | +// // Execute the delegation |
| 125 | +// var tx = await ThirdwebTransaction.Create(executorWallet, new ThirdwebTransactionInput(chainId: chainWith7702, to: executorWalletAddress, authorization: authorization)); |
| 126 | +// var hash = (await ThirdwebTransaction.SendAndWaitForTransactionReceipt(tx)).TransactionHash; |
| 127 | +// Console.WriteLine($"Authorization execution transaction hash: {hash}"); |
| 128 | + |
| 129 | +// // Prove that code has been deployed to the eoa |
| 130 | +// var rpc = ThirdwebRPC.GetRpcInstance(client, chainWith7702); |
| 131 | +// var code = await rpc.SendRequestAsync<string>("eth_getCode", eoaWalletAddress, "latest"); |
| 132 | +// Console.WriteLine($"EOA code: {code}"); |
| 133 | + |
| 134 | +// // Log erc20 balance of executor before the claim |
| 135 | +// var executorBalanceBefore = await erc20Contract.ERC20_BalanceOf(executorWalletAddress); |
| 136 | +// Console.WriteLine($"Executor balance before: {executorBalanceBefore}"); |
| 137 | + |
| 138 | +// // Prepare the claim call |
| 139 | +// var claimCallData = erc20Contract.CreateCallData( |
| 140 | +// "claim", |
| 141 | +// new object[] |
| 142 | +// { |
| 143 | +// executorWalletAddress, // receiver |
| 144 | +// 100, // quantity |
| 145 | +// Constants.NATIVE_TOKEN_ADDRESS, // currency |
| 146 | +// 0, // pricePerToken |
| 147 | +// new object[] { Array.Empty<byte>(), BigInteger.Zero, BigInteger.Zero, Constants.ADDRESS_ZERO }, // allowlistProof |
| 148 | +// Array.Empty<byte>() // data |
| 149 | +// } |
| 150 | +// ); |
| 151 | + |
| 152 | +// // Embed the claim call in the execute call |
| 153 | +// var executeCallData = delegationContract.CreateCallData( |
| 154 | +// method: "execute", |
| 155 | +// parameters: new object[] |
| 156 | +// { |
| 157 | +// new List<Thirdweb.Console.Call> |
| 158 | +// { |
| 159 | +// new() |
| 160 | +// { |
| 161 | +// Data = claimCallData.HexToBytes(), |
| 162 | +// To = erc20ContractAddress, |
| 163 | +// Value = BigInteger.Zero |
| 164 | +// } |
| 165 | +// } |
| 166 | +// } |
| 167 | +// ); |
| 168 | + |
| 169 | +// // Execute from the executor wallet targeting the eoa which is pointing to the delegation contract |
| 170 | +// var tx2 = await ThirdwebTransaction.Create(executorWallet, new ThirdwebTransactionInput(chainId: chainWith7702, to: eoaWalletAddress, data: executeCallData)); |
| 171 | +// var hash2 = (await ThirdwebTransaction.SendAndWaitForTransactionReceipt(tx2)).TransactionHash; |
| 172 | +// Console.WriteLine($"Token claim transaction hash: {hash2}"); |
| 173 | + |
| 174 | +// // Log erc20 balance of executor after the claim |
| 175 | +// var executorBalanceAfter = await erc20Contract.ERC20_BalanceOf(executorWalletAddress); |
| 176 | +// Console.WriteLine($"Executor balance after: {executorBalanceAfter}"); |
| 177 | + |
| 178 | +#endregion |
| 179 | + |
94 | 180 | #region Smart Ecosystem Wallet
|
95 | 181 |
|
96 | 182 | // var eco = await EcosystemWallet.Create(client: client, ecosystemId: "ecosystem.the-bonfire", authProvider: AuthProvider.Twitch);
|
|
0 commit comments