@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: 1704409560 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.0995, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1704409560
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.0995, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x2673DB9C8930D8E2348CF6F8E9A8438FE0102EFC09E9A7855B0482499315F860,
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: 0x00000728082646346C9BF3676ED7E29407BC1D2073286F694CB4E783ED9817552E80, amount: 0.0992015, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 2.985e-4, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code ""
end
"""
Contract.set_code next_code
end
Content (0 B)
State (0 B)
-
Secret shared with 1 key
Encoded secret
96A88E1550E5764DB704F4E6E10949DAD003515463F06C630BCCE428FDD74E7C1BE19AB3E21A4D6320F0DB9C30417A74C00C79FF7607B6ECF2E65BEE
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 00008DEB...379Arequest_funds
[ 1704409560, 0.0995, "00000728082646346c9bf3676ed7e29407bc1d2073286f694cb4e783ed9817552e80", "2673db9c8930d8e2348cf6f8e9a8438fe0102efc09e9a7855b0482499315f860", "0x573bc8a16415f649c21204be0352c18308c283083fe686c7829ba5eb222a4f11", "0x50c6c6025acb7287b8bcdf6830ed7b08c3cb4cc3", 11155111 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 000032C6...F7D8At 2024-01-04 21:13:41 UTCAmount 0.34362918 UCO
Previous public key
00015D84EF107DA352B2FE3F8C4E198D1C3CEEA8CFA2120C73D7A92F3C4919960242
Previous signature
EE20C27732BC36A58653CCA88B8179746BB37BDEDB921762C2E209F79AD8B71DAFC1060EB2AD21518BF97A18DE4CF245118DBDDA443A1DEDDD1EC789C36CB40D
Origin signature
3044022067D0DFD2301A0CC4A598D102F878F8E8256D7C9140AE3CF79A430B50849179D202201DB1CAC96E7D46BB404073E8EFF9793204766CC81781C37348B0DC2067CC4D18
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
009611AD69C007E955D70BC5C53FA81B0F74B3290A4D785607A30A9F9B370F30D1
Coordinator signature
DA308BF6C2EE0931FF910163086A9A6C9509CBB8FA2B12E68458AB538BCFF0CACC36F6B111B9B958BCFA05D96082E4EBD4948975356F70F0A7A0128E56E62201
Validator #1 public key
000134772A943DC0F7038B1BABA39E18841C12DD6682B1B6D1D15E08D7CAF5339AB0
Validator #1 signature
1CABA4234882E67BA08A7B35F2110ED324CEFD9E7E2D9F3BA9363688DB5112B200967B73E9C893E3933BC184942ACA1B73E5355A9BD2B7AF1FE8D626D1049405
Validator #2 public key
00011ED0B570D680BE5ECD58D2D121689DA73C46DCB38A01C6E10D06286040ADE30A
Validator #2 signature
FFCDEC17AAEF79DB34F38A1FA46788BC651F4BDF27389B7B8AA0C1D5A26118D98BCC3CDB890DF059A3502BB4E02F42422AB44134DD2F4B8FD5E1F03C7051C20A