@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: 1701769620 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.4975, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1701769620
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.4975, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0xCFDAEC6EC316DF37E3A6CFC2018C7339183CBAAD8C1517B8A397BEB3859E145F,
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: 0x0000F25C3DF408399FD5CC26D5A53C4081F6D6600B04B5EF4E41836D384F8B84C772, amount: 0.4960075, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.0014925, 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
335841E1A86ADA8C7D49E9CCA36D2AD767528FA3963752BAA1F424DCEE61F08ED2DA8D0C3F629BC7D13ECB7BDBC122565CA5D97BD208D870B6D657EB
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 00005872...AA50request_funds
[ 1701769620, 0.4975, "0000f25c3df408399fd5cc26d5a53c4081f6d6600b04b5ef4e41836d384f8b84c772", "cfdaec6ec316df37e3a6cfc2018c7339183cbaad8c1517b8a397beb3859e145f", "0x2aadb8776bdf82f01cb084fb743731ee21a63ae3d3d421357425ffaaa51c155a", "0x0e5e0d16fcb19cb0a26598f5813ed94a3d7d6ad0", 80001 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00000214...8392At 2023-12-05 07:47:18 UTCAmount 0.36621154 UCO
Previous public key
00010B1A37D47D1E59AC730E10CFD24B69C6C8909B5E135DCF46AF063EF11C186F3D
Previous signature
3EF72EE2EA3B695B84C8FB9BB2BD1E588B9BB1FE4A866C443F34F2D163B571282DF4063BCAC3DB260FE937F6D7EFB18EE4994944797705BE4BC328D41C67D60B
Origin signature
30440220537363922CFB2EFE9A443DBC7FE23F391106EFE1EF45CD3770D155EABA17B2BA0220361998283B4DB960CC8A6FA423B97320C54B89C7F54D32259707DC1708C305B7
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00308B577BF11DF8E32BC440155C9B5278914AE69535C741004C5DB8EE58D7649C
Coordinator signature
4A37B767DCDE773087939FFEE6FEE31CCC50136A1ED3B67662D8E7BC8AB0F8096FC70E6B0EE480F92F56D5B13A80BC9E7F235E91BA148270764EBBA1DCFFCD0B
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
7A7D93A7CF3FEB77052F2F9653CADD4642EA98B9E4117B7B0FF578FBA3D681F9BF05DD4A7CBB0B55753FB968D1CE98C7C8394AE9670E17CC5B32C235A1B9DF0B
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
CAE5CB44C32380280F6784F40387543B0956EA689648D3EDF04951AF8008D84D5FD72D1154093BF50D027B4DD073A46E5B0CB093F2D2C4878E3163F24044D906