@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: 1705283580 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.2985, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1705283580
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.2985, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x776B5BD9C853F49D4A83280B30B7FADACC5326DD77ED3E90CF070883F269AF24,
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: 0x0000F20644B2DAA3361C435E92050CD1EF0302EDAC8832055AE0E829FF6DB3D5EE49, amount: 0.2976045, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 8.955e-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
F6961FB9C8CC5B9CC5E7CEF8972CDEACA894AB6B1060CFC030F0A8BE6DAD6B52E80DC36FEEDDEF900CBB6649726CCC3C14DFBACB726487267EFD85A4
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 00001AD7...0832request_funds
[ 1705283580, 0.2985, "0000f20644b2daa3361c435e92050cd1ef0302edac8832055ae0e829ff6db3d5ee49", "776b5bd9c853f49d4a83280b30b7fadacc5326dd77ed3e90cf070883f269af24", "0xcd2bbef9d7b07b9d3ea9c014e71541d65a2c93244ea9fa590bc4a48e3dc28552", "0x69f8b39260a9cc3e7679767549ccc5702496b940", 11155111 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000EB5B...97DAAt 2024-01-14 23:53:59 UTCAmount 0.39926883 UCO
Previous public key
0001C6EF5E2E29E24DE9350960FD830D811EB97C0143C16B2FECF9CDB28CEE95E8DD
Previous signature
68F5135F2F216640966EB529BADC504348ACD794956B1684F0FEEF31BE58E99E53754EBC193D5AA185C4313DF7F53B1BFBCAB9E7CC7F2FC408CD3049E6D32408
Origin signature
3044022041A29DDA2D107157EC7B0A16912C20B42386A4EA985544D9F78707BCEBF90CFF02203A8E03F6A30C42D1C2E9D21B2CF5AAF63415C3473043C93CC1B2EBDD30432011
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00D910EB9FE5374C96E9A6283D5AFC07AB0F89F280DA001B0876C8539E379FED8E
Coordinator signature
3255C291901F39F85418EF472F3DA25AFDA63ACACF06055C8C3F1771A1515F203A907DC81AB81C5CBF1D58F56DC41CE9CB19E97E165BCC2140A3C45A097A9F08
Validator #1 public key
0001B01EEF96BA7E95FC844D456CE8868F18864519FC9532E1751C2035FD044DD5D0
Validator #1 signature
ABD785B2BFEE69D263AF91BC850859CB74E31056FFD10BBD027415E89EEB52374D438F4AB3BF926140E550F346A9F2AE8A5D190F9D7266A0D8DAA4B2347A9004
Validator #2 public key
000103E30584AD8DE66F9E29419D5D0ABEE5A76722C9FD0D012BDDE3A6E2B149C48D
Validator #2 signature
31249AABA54D51A9542E96F3F71DFB7D11862675D9678E351CE9A98D3D3C6437E7F994F06318D8B2EAEBC59564BD92C884AF63F2E8B6B366A0165DBCDC05E408