@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) == 0x0000072E418B60C6DABD272BC2728B17B352B8104F068D11365D50134F96A4199609
)
]
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: 1702759620 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 2.8855, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1702759620
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 2.8855, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x4766930744F2574DB7F1D8F5353171A37DF462D501CD44EAFCA6F7D20F2D6150,
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: 0x0000FE614CE4B98E205ED3AC45CA88D39D1F27B1A0589194902198825F0E6027AD2C, amount: 2.8768435, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.0086565, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.set_code ""
end
"""
Contract.set_code next_code
end
Content (0 B)
State (0 B)
-
Secret shared with 1 key
Encoded secret
E0628478F780083A9B4A50F465117A677BFB8E56BB8705D1D861939AA7000529862472859C52B19724925B07D1BEB6DED608E6C1B75F472449603C4D
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 0000BC32...5254request_funds
[ 1702759620, 2.8855, "0000fe614ce4b98e205ed3ac45ca88d39d1f27b1a0589194902198825f0e6027ad2c", "4766930744f2574db7f1d8f5353171a37df462d501cd44eafca6f7d20f2d6150", "0x301bfc38fa67e65d2c2896618cf6000976e318f89eb35b716013c0d85ab0cf3e", "0x65c633349d8fb956f53f3138c785324421d7aadf", 80001 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000CBEB...FC5CAt 2023-12-16 18:47:23 UTCAmount 0.38886902 UCO
Previous public key
0001DADEAF177F87325A4051C765D80C7451CF64C6FEE012576645D31AD728B178E5
Previous signature
B58FBEA855AFE0813B7AF946F0AAAE42B7276CC7F2C32FF57C6D91B61A6022DDB01882A59A6BDFEE1E4DC8DAA6A1D8334B993015727F2B17C520CAB1CEACFA04
Origin signature
3045022100C5DE4CEA2D13AF97E9D5B7946EB97DA5682346E335ED4C128F51E7644761F55E02205A9A88FC08C39FCD3F289787CBBD08416FBB17B2826EEE7F62E162606C466366
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00D5FE2B29A854A7637375E8F34E33181A884BA2DF3620B1465043BC9A0B5260FF
Coordinator signature
B2F1C4C0647D6E98A093A4737FD7D46D7A215B28FAD6B71C84ADCA1805EFE5C9BB42A78D249FE8FD2E58972C87670F790E4D6D8228FDE9EC31275A08FF3B3C04
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
E28819C3E4202434977C74FEC151E2A1D9D885C5EB1C861A08B75FC97098873F4A6696AC2F55A19EC1159530868311EBDD864C6E95A14E8C646DEFA251860A0E
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
70AB4374B7DAB3A4CE61590F4C360E4012C2495542C4CA9131754B53B44A1E958B7802A3700FA901F5CBB78AAAA9D56C7D998699CF457F79D1B329A57B83B009