@version 1
condition triggered_by: transaction, on: provision(_evm_contract, _url), as: [
previous_public_key: (
# Transaction is not yet validated so we need to use previous address
# to get the genesis address
previous_address = Chain.get_previous_address()
Chain.get_genesis_address(previous_address) == 0x000066706D704329CA8C2A4153991E2DDACC968622CA10217CA14952EB7ABB966C30
)
]
actions triggered_by: transaction, on: provision(evm_contract, url) do
next_code = """
@version 1
# Automate the refunding after the given timestamp
actions triggered_by: datetime, at: 1698660900 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 1.0e-8, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1698660900
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 1.0e-8, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0xA9BBFDB0C5DE328734C290E42E34AF50230E547124CF92A39D7EC8DA2955323F,
address: (
valid? = false
abi_data = Evm.abi_encode("status()")
tx = [to: "#{evm_contract}", data: "0x\#{abi_data}"]
request = [jsonrpc: "2.0", id: "1", method: "eth_call", params: [tx, "latest"]]
headers = ["Content-Type": "application/json"]
body = Json.to_string(request)
res = Http.request("#{url}", "POST", headers, body)
if res.status == 200 && Json.is_valid?(res.body) do
response = Json.parse(res.body)
result = Map.get(response, "result")
if result != nil do
decoded_abi = Evm.abi_decode("(uint)", result)
# Withdrawn status is 1
valid? = List.at(decoded_abi, 0) == 1
end
end
valid?
)
]
actions triggered_by: transaction, on: reveal_secret(secret) do
Contract.set_type "transfer"
Contract.add_token_transfer to: 0x00008DD40CD42287A3C8282065F5BCA7259AC7014CD73109B570E946A977687C7BD0, amount: 1.0e-8, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
# Transfer fee is less than the minimum decimals
Contract.set_code ""
end
"""
Contract.set_code next_code
end
Content (0 B)
State (0 B)
-
Secret shared with 1 key
Encoded secret
5B30FBA63EC07CB7DEDD5DE609036716ED1288771B1D67FAEF2AB2A30E8661D53CFF826F1D0FE95F5A37E3D6E918AA53D0AF6B150550F7636083A918
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 0000C361...0D62request_funds
[ 1698660900, 1.0e-8, "00008dd40cd42287a3c8282065f5bca7259ac7014cd73109b570e946a977687c7bd0", "a9bbfdb0c5de328734c290e42e34af50230e547124cf92a39d7ec8da2955323f", "0x273821df46df7568b88680b6b4859edbca14eb24ba23054cb5dfea697edc65e8", "0x77885c302a20b6fdf5b2271f3a5d5cc27b32c68f", 11155111 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 000024EE...74A4At 2023-10-30 08:15:50 UTCAmount 0.47354637 UCO
Previous public key
00014EDA57DE3F455BF47192B8E9BE38574E0D5B66E874DA27EABA6FAD173FCFEAF9
Previous signature
BD567AEF3601605C5BDD94C80DE814BF48370B71CA2AC0C90D3DF04BC643697BDB598536EB5A63E099FACC199E9B4636EA780AEE8D8A8E22BF379337F1E0C006
Origin signature
304402200CD0249FF4E03A21862BDD29CBCDD2EDDBA9CD04A3A2CFB4E1F9A471F4099DA0022025E69D309809B6588CC2D81379C6DC847CE355F44B97A4EC64C88C8442432E44
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
003C0123D9856235A9B0163F2439ED5FBDEA426358BBE1BADD64B65CC03321924A
Coordinator signature
9A1FDD93BE401F707FAAD4B82039410221C2A45D21012C736509BCA66E1464096F3DC8FBC12A7FCDE0A8036366E859ADE4B08BB9481FC03D042E67DB4A7A8308
Validator #1 public key
00011ED0B570D680BE5ECD58D2D121689DA73C46DCB38A01C6E10D06286040ADE30A
Validator #1 signature
0F1D2DAE10B2D111B76B3C1A1D7D31F95E48A80AC19ECC93D5DD8399FF71C1C14C259B214C9D778104F69F6AE4920D7792DF54C0EADE95749619DBC680A3AE0D
Validator #2 public key
0001500FBE298B79FFBDD5CCA1798F30FD88A53D26EC39DE5DDE1F4137B032A4BC34
Validator #2 signature
8AE828A20EF7AB274B6911A769BF42A0265DF28F507CB114F8414850C94816A873163B5FB717978FD707D7BF2022CC15CF8DC8970A28DED3A6F27429DEB1B40B