@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: 1701341160 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.0995, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1701341160
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.0995, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x179119A412E58C384D40901DA53154FAAB3905AEF6292920245211CF2BA751F9,
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: 0x0000083A1B345FA78DABC772F1FDADB9DDCEEF7AB2F28208EBB6593B976A7E631882, amount: 0.0992015, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 2.985e-4, 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
287BB460AAD324CA286824CFCBDB2383C09F4C75F543B619014A8D791F13C1102F78B6FF18A82CB02272886CAA30F86A7733131FE1CCE0AD74FF7014
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 0000320C...6596request_funds
[ 1701341160, 0.0995, "0000083a1b345fa78dabc772f1fdadb9ddceef7ab2f28208ebb6593b976a7e631882", "179119a412e58c384d40901da53154faab3905aef6292920245211cf2ba751f9", "0xf9a2ee9e9b4563adec71a64370ad97861a14e741c485ec748a5257632a7690dc", "0xa0807ff65884b8f4e3d5ae3b2ed5436004b864e5", 97 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000FD02...BA90At 2023-11-30 08:46:45 UTCAmount 0.3602189 UCO
Previous public key
0001CCFB6DF8B72D26660C9711A72ED6A89980AAD312DDE90579174240393EB1E46D
Previous signature
708428AE3E76AD98F365251C154BB3C367FFFB04C4766D10873176DBE8B9C27044C02FF6780992C59A3F88B71B0A80ED0F30DBE41B43BDFFBA42930A63D53B05
Origin signature
304402204716B9A9DE3A780C530F807EA475D1DDD9D7585DF2C34AEB74DAACDFE56EE34B0220658073A202A034314E362913BFEEADD9D2AF0805165FB524D9F5B4943A9EC268
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00FE0D5401DDECC3FF6B6687BFEB29239D345E83D6DFB2D633F66234225A343EF5
Coordinator signature
F43B96A957D2154724B8B11E43440FD3E9E6F149BDED1EEBBA367E531F0B9E9637400359A88D173AB33A1C5D7D3ABCA17907388524FA531C26FF70D16B549209
Validator #1 public key
00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947
Validator #1 signature
F3012B295797672FCF58E6548060504F409659D63A34B30BFB7004A3EBEE74DC5136D6FC101E12C32F7B4FAF65B0298B58C5C81058577E94264302566B2FA60E
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
2260F2B199292E4CF138FBAAF0F6D00F245A5C3171B6367E0580890EE22459DF0865AAE814C34669801483703EDFB015D7147810A5FBD614205FEE37447DB209