@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: 1701799200 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.2985, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1701799200
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.2985, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0xFEAF948D1A869C5E4A8079ACF0DA334FAFB63D66C9A501862AC825B2D413A976,
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: 0x0000B57F380A6FDD0E091BF06894748657AC79686AED964A3F2A9DD87527632F6AE3, amount: 0.2976045, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 8.955e-4, 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
7A931B88EA732C85E81BF1A513D3291793D08A9DE56F8F0CAA611C014DEC63BF6D74DAE7847ADDEC4C9DD87837B6D9B5CC8D3404F19CBFAD27E5A49C
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 0000CE63...6E08request_funds
[ 1701799200, 0.2985, "0000b57f380a6fdd0e091bf06894748657ac79686aed964a3f2a9dd87527632f6ae3", "feaf948d1a869c5e4a8079acf0da334fafb63d66c9a501862ac825b2d413a976", "0x6b9755b5aecac6f9504e05fd14173c501194e81e697d421c5d0b4e7151b8d7bc", "0x4b2e243a05ca255a311df18f257a9f4b6f5be027", 11155111 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00006105...425CAt 2023-12-05 16:02:56 UTCAmount 0.36760753 UCO
Previous public key
00010D0C9393D16691E51A5AAF61969EBA6A0C88C37C057B74E6AE50145502D25FE0
Previous signature
62A377E1DDE3ADCB10A594501DBFE84596D505A1FDE4E62E6A6661FA345DADF433751C6288DD43DDE0C0DDCE287DD3C1F60557401FC4D02BEB216CEDB43A9609
Origin signature
3044022001F66097AFD610DE0CB313C7B802C800C0677AB54FEA0406FAA068D72F71643902203026AB9E7068DBE12E52E1ECB1DEC50490EE913FEDFCA9B55E455C90BC35D98A
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00775115C0882F86B522B8F10BF60C28F1B342A725D1B360766693616C6A03157D
Coordinator signature
3A14A39EE94B8FF5D140D7D04C36A5A842EFF10A09CC91528849C47B59E5611A4F395416BE8C6DABE4F4B6E7F7D963BB01B4E41EBB9AAD5ADCA74D224A98AE0C
Validator #1 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #1 signature
2B1CA18FF45EAB676F9B0DD0DE4E1B2C109A459C69F9DD9C0C2B0FE756D10B0B8378FCD4061B2646DEA0C938ECAD015EFE829A56E2B933287C86E7F3DCDA4E05
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
258E4D309CB6444F33F0F2B26E1D153449286B73B657C07F6E0827271BBA894AC9B4BE1F53865548D8A8D5D780B75D5C242282CA2FA2BBD7747CE94179CFA002