@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) == 0x0000072E418B60C6DABD272BC2728B17B352B8104F068D11365D50134F96A4199609
)
]
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: 1706204760 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.199, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1706204760
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.199, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0xCC74FBA180654C5C78ED30951860508972896ADB4A291F7A0C12D550D11CC535,
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: 0x00006DF0C3F3EDF04270B7DAD02E80FF9291F01A6797DCCDC062D77606B99D4B230E, amount: 0.198403, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 5.97e-4, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.set_code ""
end
"""
Contract.set_code next_code
end
Content (0 B)
State (0 B)
-
Secret shared with 1 key
Encoded secret
8F6606EA02058CAF1567018D80A0F294922CF9F6FD9E08D49CE1A8998D352B1879F53E6CAC20BCBDBE08F79B9C10FE25FDF09DB55E2ED19E22D79DAB
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 0000E906...E3F3request_funds
[ 1706204760, 0.199, "00006df0c3f3edf04270b7dad02e80ff9291f01a6797dccdc062d77606b99d4b230e", "cc74fba180654c5c78ed30951860508972896adb4a291f7a0c12d550d11cc535", "0x424aa20736a86aada0c38dd263f01e26161c79d239c7128b622576225ccbf6c3", "0xb767fea7bb93f31c97519172af30e170916eadda", 80001 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00008E02...298BAt 2024-01-25 15:47:20 UTCAmount 0.37573481 UCO
Previous public key
00015A2368E429171DE4203D31BB16F372D59FD4DFF9F51CECA8474749AD571109B0
Previous signature
E769C1E92B3481DCDC1181C69939CAAD27DADD2EFB8161945055E28CB8F4EDAFDEB108791A54748345D4C6F1C16DC96764A198B75098EBDACD51593864F2510E
Origin signature
3045022100C89DB28F61CA5BE82A706A0E6EFF1074C71CD7CF2745D450582C7DD8B1B10B9002203EDEDA6E2F1627CB24C7675EDA93F258B39710CBA6FD387628B1455BF39AD67E
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00BE5B167C831D5ED4AB27EA1261EF91518B8B84FBF917DD73C2B317F4DBBCFCC8
Coordinator signature
F081DD235CB5A766E3C1D8AD05F4C1BA22AF0014D10541F90A4E1781DD21E3DD3D04A10196C5730365D5B5E2B271AC378F1E6372A1F10E1EF4B5C77887E8130F
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
E6B99ED63D7E6A30337CE8B761684DD7433333EBF9A9096B2CA63251F31D2B5D7CF33B5373CF249C32521DFFA592773D9C3F8261D88DE6BBFB4CEC91E2A62807
Validator #2 public key
0001500FBE298B79FFBDD5CCA1798F30FD88A53D26EC39DE5DDE1F4137B032A4BC34
Validator #2 signature
5D0E0E66CD924A8646BA5BFC8DB768C14CF19AF89FC842C28A98A125B214C5EF4B888803EF28DE5D93D62F913293A86E24B64622E7E78F8FF6AFA88D3C3D360B