EVMSEALEDEVM
&■╱■▓^▒&%╲●▓●●#╲▒╳╱░^*■╳░▪%○▫@●?*▫▓~╳#%▪◆$$$▪▒*○▪$□▒^◆$$■■●~▓!▪▪
Transaction ID
Transaction Summary
EVMCalled EVM
EVM Hashes
Contracts
Script Arguments
0hexEncodedTxs[String]
[ "f8db820e858503c7dc378083079cd494088a698924c9530ad9b55c6b1436fa31f3b3809a80b8716c05cd2b0299af3eea856556646c98c8b9b2548fe815240750000000200fdba612fea7a7ad0256687eebf056d81ca63f63000f368800000000fc18d92085fa9df01be5985e5d890b4a4d7edad9010f36880000000000000000000b796e0620e6000000000013da4bbdbe73a91a17a5d06b8205faa0e3a4ca21485ac3a3943be7da80e52394f41729647b72050047bee563bc9c705aa050d70d20e663b93739417846d0d21beb00a567e40b183d25afba9945e6d33db5" ]
Cadence Script
1import EVM from 0xe467b9dd11fa00df
2
3transaction(hexEncodedTxs: [String], coinbase: String) {
4 execute {
5 let txs: [[UInt8]] = []
6 for tx in hexEncodedTxs {
7 txs.append(tx.decodeHex())
8 }
9
10 // If there's only one tx, use `EVM.run`.
11 // If there are more, then use `EVM.batchRun`
12 if txs.length == 1 {
13 let txResult = EVM.run(
14 tx: txs[0],
15 coinbase: EVM.addressFromString(coinbase)
16 )
17 assert(
18 txResult.status == EVM.Status.failed || txResult.status == EVM.Status.successful,
19 message: "evm_error=\(txResult.errorMessage);evm_error_code=\(txResult.errorCode)"
20 )
21 return
22 }
23
24 let txResults = EVM.batchRun(
25 txs: txs,
26 coinbase: EVM.addressFromString(coinbase)
27 )
28
29 // If at least one of the EVM transactions in the batch is either
30 // failed or successful, in other words not invalid, we let the
31 // Cadence transaction succeed.
32 for txResult in txResults {
33 if txResult.status == EVM.Status.failed || txResult.status == EVM.Status.successful {
34 return
35 }
36 }
37
38 // Otherwise, all EVM transactions are invalid txs and can't be
39 // executed (such as nonce too low).
40 // In this case, we fail the Cadence transaction with the error
41 // message from the first EVM transaction.
42 for txResult in txResults {
43 assert(
44 txResult.status == EVM.Status.failed || txResult.status == EVM.Status.successful,
45 message: "evm_error=\(txResult.errorMessage);evm_error_code=\(txResult.errorCode)"
46 )
47 }
48 }
49}