@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: 1702471320 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.00995, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1702471320
]
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: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x5CA056DDC1A0BB3457BC5B37092F37032AF1DE8E375D8DAC78BF559499CF8C8C,
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: 0x00007011C3312E6DD64C930A68B7B5F99AA6FC8FAC555DC1421BADB3091E3786B826, amount: 0.00992015, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 2.985e-5, 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
683D8EAACE4936800365B219E4906DAF8362C4249E6C682A58AA959201F5180ED8EA07DA536A7FC3B1A2C47A2C25F0E67B90CECB13C4F5A212B3D78B
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 00007725...7CA6request_funds
[ 1702471320, 0.00995, "00007011c3312e6dd64c930a68b7b5f99aa6fc8fac555dc1421badb3091e3786b826", "5ca056ddc1a0bb3457bc5b37092f37032af1de8e375d8dac78bf559499cf8c8c", "0xe799ec59089a6850eafa14780aafc4c90b2d2b3d9aa5b57b63dfbf82a8589e65", "0x0e9ed555bd0c48b60c1cff0c8b8f4095f2117516", 11155111 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000A41C...11ECAt 2023-12-13 10:43:02 UTCAmount 0.37566789 UCO
Previous public key
0001894A8940F7A3736DA18F5D147BA005BA2E8E43F8E4AFC4EBC106BCD14B367FB3
Previous signature
6C2065E111BCCB22CCA61CBBDFACD91726392F240065C293F2EFCDF353B5CBA4472B6640CABA3746BBC9D7376ECEE8B12E20DC1EAC91682E4BC75E50301DB40E
Origin signature
3044022019735F9E1CD9DC3BEA2D91077417D6D9F7987F533CB4F4EC9ECE2F6175B5C03F022047452F72F8636255315C1CC5963154BED38EF36CF391C75832C0BFCB33C736B0
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00AEEA294C05D1286D967A2848FD0826C12627478CF0884F901B1E5EA8FFF9D7BA
Coordinator signature
441D03DBE407FA4EA131451523C67115840AD494CFE31B40E9B9665826008787E8535982587697CBF8A327CF8FB82C599CA155DD1C75FFE695D4661B5BBE3203
Validator #1 public key
00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947
Validator #1 signature
22DD601E76300F562EBCC0E7BBA1D9185B414439EE210F1D0606B6781899FB3EA22AB0D195D654790896010B28D838BC757E537594595103DBF19B5E3CBC370A
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
A52FEE7E15EF36C3E61EDF31E15C1430F1055AB268757132FD92BA5C8F64BA852DE6981DFB9A2562F33D4A9EA2AB046BE5ABD76237A7621952EFBF03CA79FE08