@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: 1701475440 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.10945, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1701475440
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.10945, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x414233EDBEC1E9E29A2C3CEA2B0028268ED2B12E5AE6BA94EA6E1DEB395F2B72,
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: 0x0000EB40E8C224FEE528BA8A0C373FFD228070A36692A6ACA07C88FF83715B49E195, amount: 0.10912165, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 3.2835e-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
D1B5F6D1E0AC6AAB7F4085974A4D00797F2B9E1BF93F77213693DCB095D274054210C8946D3FEC172A8716905F5F7081871982EEE5132CCB93A90F1E
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 0000D2E8...9775request_funds
[ 1701475440, 0.10945, "0000eb40e8c224fee528ba8a0c373ffd228070a36692a6aca07c88ff83715b49e195", "414233edbec1e9e29a2c3cea2b0028268ed2b12e5ae6ba94ea6e1deb395f2b72", "0x384a73bec33f64366ee25542f04e0a4f6975c3654b2c0234913db35d5a8d43e8", "0xc9f7ca8bdfaa88a08e025bf02508f0c89bda3cb3", 80001 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000412B...EDF2At 2023-12-01 22:04:54 UTCAmount 0.36891252 UCO
Previous public key
000138C467B5D22C402F3988E60C868051F9DA8C6E4432FE24568C5C0D7C22B77134
Previous signature
B47BD9AE3CE1CC4E543B1CF1D27C92FDB21F603BAE5536015829EFC5FB43584E2E81E7D48A813BFDF323F9B050987AD7E3C9900CF2BC40D72E595DFB5FDF220E
Origin signature
3045022100DA12BDD750AA116778BE583A0344F35475A521490041DFDB4D5AD4B9BB4ECB06022042C50DD01B060EB1F46A8745C21293A56466DB78320866709D56E6013A4FB075
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
001C6A29C49E98DEDF1308AD9F1D96FAF138229799C97BA4D2E557881868F09E30
Coordinator signature
271CF03F7ED7F3E7AB7AA5AD847E0625F5FC265E6604C464697D749CAC35E539F9A78A9DB4BF08DE5305DAEB506D4A4561C895F1099B5653732E06BDFFC55C0C
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
8ECE1BCCDE75E09C10EC516A1CE49E348FD72D87B0565A1135389862C7BC343E688ED7F6D3AEB71D46C223B5AE3BAE10BC2714C17C59AD39D8A2E85E5B67B209
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
6E2A2753A4221FB15C54F037913419481EA1CBA1EAD5854A7A6E15FFAA5C23AAC7C5B5EFD7EE2777FC36A4EA8B060910351E16871304AFE2A913B63301CE1A0A