@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) == 0x00008DD22E7496E86901E9B276A1BE6F9512EB09980CC04C7B76495EF37D5666A709
)
]
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: 1701857040 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.00995, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1701857040
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.00995, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x7B34ABA2343D0A2D819BBE2C3D77BEE6B01206DC2CEAD2F598C4035C0CA25D8F,
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: 0x0000229E63A69C9885130321C9FCDDFC8149C016D1EF0371C3B48F7E44069155ED9D, amount: 0.00992015, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 2.985e-5, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.set_code ""
end
"""
Contract.set_code next_code
end
Content (0 B)
State (0 B)
-
Secret shared with 1 key
Encoded secret
5209DDCB4935C6EB68CB56E8D0528111A9B30172860FDD9A2A7C3C0D367C56F08C46DFE92EBFE6A47797C8133574D5A4357CBFE4095BE6EE2B72EBD7
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 0000EE3D...A3A6request_funds
[ 1701857040, 0.00995, "0000229e63a69c9885130321c9fcddfc8149c016d1ef0371c3b48f7e44069155ed9d", "7b34aba2343d0a2d819bbe2c3d77bee6b01206dc2cead2f598c4035c0ca25d8f", "0xfbf90d10066af433b0b71f5679da993a0cb6bb6488c6128fc91c158a062adde9", "0xc7c8c9bbff72d5a65623f79a8f9d2600c2e3da98", 97 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000213F...4EEFAt 2023-12-06 08:04:31 UTCAmount 0.36781306 UCO
Previous public key
00017216CF098B9F847B298246FE475F9F18163D3012A0C5EB814F7F1BE96BE7E661
Previous signature
10531A54549E8353C46E4F3CA0CD9E0F65D6C332E1356A54F795AAE5FA384B317DD713156946F4A9E99444D2C0855301BE90CB7802E7B268952F20D5600CA709
Origin signature
304402204CE1462A2AA5BE0264EFA52569D42A9482689BEB298667CA6D1D8B44A5A7CFAD0220514F32A1EF5BF53FD50418F1FDCCE51E393E3F1F7B9509A7BB01FB92D6561365
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00D85D56CCCD7D17D6BACD75C2DBFAA40E369C9B750E27D50274EBED62AACB3D2C
Coordinator signature
85B404992ACEC7BD9CF10702D06A4EE3E3B59E6326798D6874A736C6120C1F0FF5C07D440A6852CA6FF9A2F6EB4E503052AD6D96466882A3277F3F97D1012106
Validator #1 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #1 signature
191464FEEF8B7EF4772E1461514D77C8A2083C906A6AFB80DE8CB1679151E915D273D982DE87C0A23A2B02D7B99F63DC9CD83D107113380FE766C1FB7002FF03
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
D0BDE4AB2ABE2158C142CFA352C57013CD49DC046BE0B02CE6AD1E72EF7EA20B6D6E3D45D995ECE9E3649AA3E13B296D4BFCCB705D8826B869C2C77933EA1E0A