@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) == 0x00008DD22E7496E86901E9B276A1BE6F9512EB09980CC04C7B76495EF37D5666A709
)
]
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: 1701962700 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.02985, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1701962700
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.02985, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0xD23A2B0EA02F8668E514975DB43226FD2082ECBC11BEFBE87F7FA6A13C7FF9F5,
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: 0x00005812E57B735BA93F77AC9DCF7DFD402B8C562D8AD7AF7EF3C9B5D408F4BDDF5D, amount: 0.02976045, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 8.955e-5, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.set_code ""
end
"""
Contract.set_code next_code
end
Content (0 B)
State (0 B)
-
Secret shared with 1 key
Encoded secret
884F06604805A3F0AEB220B0B7400EED038FA7B464CFD1D81BCEFEF8C31F0FF78BF70A1AB3116DBCBA1CAB9A4B95A6E527CD1C6226172EC8BBD32EDC
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 00000C00...3C93request_funds
[ 1701962700, 0.02985, "00005812e57b735ba93f77ac9dcf7dfd402b8c562d8ad7af7ef3c9b5d408f4bddf5d", "d23a2b0ea02f8668e514975db43226fd2082ecbc11befbe87f7fa6a13c7ff9f5", "0x78f33c01849499ba5977e20855cd393c5f5fef418c1a9b47c8e10eba307aa113", "0x40dc52114032aa8079821e3ed4a84394914f7e0d", 97 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000D390...0BB4At 2023-12-07 13:27:03 UTCAmount 0.34246478 UCO
Previous public key
00011B91F6B9C4B76733E94509CE57FB59FBCF6FA9A7496D1E81508A6E0820F55DFC
Previous signature
2AFF5E1740678AB6930EE58FD7754920CF2F2D0EA17237FFE3C7C558794467A3F47D232F1B53B70C14F646EAC6A3170E2742F5579D97CF5644BA78F6A1E33105
Origin signature
3044022054C3E7BBDCA62685D5C9F238BA5972C1CE405A039A4D277C75A61D63AC3D7F1502203F360541B57C91D1442D688C8522E4A0D6A3BA5EA6300FC717FC3D33955F4C17
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00A4C9CAC3645BD13C22749D3771CF2CD1F5C8B5005D262968B4851682BF5036BD
Coordinator signature
177C59A93E4D37A93F7DDC909CECCA8EA01E323A7574DD327B424C96266F9ED4E1F25AB44DA884B5BE323DBC57377EE537BA96BBB1A6EB72B2481CFFEACB2700
Validator #1 public key
00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947
Validator #1 signature
097D5BDA64920DB2B94FAF2AEFC3101F7CA670D2D79BD7262A633E125330731CF2C92968AFA10C9696791AA7F7CFB0E15A57639A65B52905C4AC4F408726270D
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
E6627190A481CF89961959EC1744F913A5E279D784A833B6ED842B04DDB5FB88BC86A5E37E5143F2567AABD15EE0975CDC4104F550A489475088096393362602