@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: 1706636640 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 5.4725, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1706636640
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 5.4725, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x25BB323D00BC3C95F451526E8FA76CD7F85C2131B3D7E6A02E1180E1428CC0C6,
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: 0x0000834AD179A291856494A6ECA9AA855AAE0F28E5F221666CBD11D2FF96B2A0FE19, amount: 5.4560825, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.0164175, 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
44CA0BF867654D6FE5096C5B6B295E47CD5D9F065C51578AFE8CE02A95A3AEECA2E302E679C4274754E2D91C85C3CB2D8ABF0A6A6A4419719E6EF651
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 000013C6...23FFrequest_funds
[ 1706636640, 5.4725, "0000834ad179a291856494a6eca9aa855aae0f28e5f221666cbd11d2ff96b2a0fe19", "25bb323d00bc3c95f451526e8fa76cd7f85c2131b3d7e6a02e1180e1428cc0c6", "0xa2ec2edb2dc6cc98b35eb8f3f5ae941faf19cf0663831a8f80e583e4a75e549d", "0x5e02a23ee44cabb92705fcfa7926423bcbb92d73", 11155111 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000738A...C3E4At 2024-01-30 16:48:31 UTCAmount 0.40161796 UCO
Previous public key
0001AC4DB4CF026337CB75FF1E43FFF260BD461367932262A1C4562AC69D7FC0D98B
Previous signature
4AA48A01B620B2B0B035DF59F6A8F77150FCFFA76AE1431392295BB2F357D981E12F60F66B60CCAB410E12770DFFE4BD016B82CF4C6E4457A0440DFA879F0402
Origin signature
3044022049BD2E7A4F4ABF4FBA9A5F76E8B7FDBAE97A0565A05F41EFABFB1AEB60658CD90220014A4B25C638DF38CF5F99064AC65A5F98250C16968D787FAD647329FD72B03F
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00B79E4A657CBB22476F710CECEE00B52E5642191DF8C88CA31FF41F00231A6B69
Coordinator signature
363003925EC2521704FC710FFBF90A35AEFB6CC8DD2B7E00518D30C1402BD9B10BE0D7DA82F47F25393F4B3156E657F9A299FA39FDA140DE51954CE4AD3C1D08
Validator #1 public key
00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947
Validator #1 signature
A0657624C1D8AAB119184E04EA5DB82BF0C35638CFC1899697232FECDB1C24737AA2D0D71AF35C55C8E765A11A70D3BD8F786FD49B1DBC2C54981EAA8C3AE40F
Validator #2 public key
0001B01EEF96BA7E95FC844D456CE8868F18864519FC9532E1751C2035FD044DD5D0
Validator #2 signature
09316D440DABA2FB5224B9530316E2FB2B60F07D264B151C0D5C617ABA67DF004A467D07CDE73D5FF687B63FE49D670CFB60124F18BE037050D4F4BAD510BE03