@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: 1702144980 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.04975, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1702144980
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.04975, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x2DE61CD3ABC9D046C2B411F9A2DA20CA49DF61AC16B90D44D6283AB206CC0D92,
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: 0x000013D93164964EF03E7301038D10D006BF95A080C01D88427736C672EE22409C00, amount: 0.04960075, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 1.4925e-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
F8D91E20778A3EF4E4BCA987B32ECC7DA85D7678C27A6389FD29C4A2ACD1C5BDC709FC044CDED001BA9FDAE8219C92591B825101F1A50C7C21330079
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 000033B5...5B1Arequest_funds
[ 1702144980, 0.04975, "000013D93164964EF03E7301038D10D006BF95A080C01D88427736C672EE22409C00", "2de61cd3abc9d046c2b411f9a2da20ca49df61ac16b90d44d6283ab206cc0d92", "0x307b7a5fc9d1ad3223e30796ce8c142e024a742b5961b33a102ca6eb78a745c7", "0x917a033227230e51833d39763b666847d88cda9a", 11155111 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000D0B9...5679At 2023-12-09 16:03:59 UTCAmount 0.35334143 UCO
Previous public key
0001505C24A7A10DB8A61EFC9B2A1BEB75DC81745D22616C341BB9BC0E34E127F757
Previous signature
C8326078BBDC7C5496ED83C13E5EEF9A681CAB1660392C774D388B706FB2D4DD0826F241D4F1170EA55A33FFDEED7BE24498AEA4C277B5421AE8D0A8F2BDFD05
Origin signature
304402201755CC0D03338E1DB2EA08B5E46571AE28C3D4650B23E93CFE0D1EE40B9F075202204A529C6C9DB96BFC4B8D10C69853D06967C94A21D295334ED18E8242F0975D3D
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
004B8F7DCA919EABE4592A3098294EB7CF1B5BE5F9B651C531E6EDD8FEE2C5CF8E
Coordinator signature
43C155540F52593D3EA5DC36EDB4E3663FFB22F3E883B10246A17D52826268BC1914BDC90237BE3C1302FE7034D41B55CBAE15EE1EFE17F4CFE0B338C4AAB207
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
4F351ACB3C2726594B2AAB74FD88E35C9F7026269FB70B1C22BEE867C8DFCAF96B590FFCD4623ED2C0F5B4B5A1B3AA92678CA56AE533E532178B2762D53AE200
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
DCA7CBB60B87760CE93D45E8A251536AA639BC5CBD3F201E26B3DC2010B64BE4E99A71AA364F09D8EFEC9F82EB432D47D70EB6F96327B1B5D72CB74248816507