@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: 1702603680 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 3.93526357, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1702603680
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 3.93526357, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x8B37779100500D33AF3697FC9D88405474B4663D5C11BACE8467051978E5C3CE,
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: 0x0000F3D9160C94DD20C903E2C7BBC4AA7C607F4DD93A52FBCAB186464F3D8AAEE1BE, amount: 3.92345778, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.01180579, 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
BF9A31F639AE9E0EEC41CC6D1B559BD12A1F346A02AC7F7FC87CAEC58CEC5FA4A398B02A9CCEDE821B72F633F7A2838160B4B27B2BEC997644BB400C
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 00001D37...654Brequest_funds
[ 1702603680, 3.93526357, "0000f3d9160c94dd20c903e2c7bbc4aa7c607f4dd93a52fbcab186464f3d8aaee1be", "8b37779100500d33af3697fc9d88405474b4663d5c11bace8467051978e5c3ce", "0x5562cb474026f4bc9d415d1c7951cbacc6f39e9131e44bff1cfa1d6a9f98969b", "0x25d6a30fc6b62f5f1b63762182d87f101b98a034", 80001 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00008347...83EDAt 2023-12-14 23:28:27 UTCAmount 0.38395849 UCO
Previous public key
00014DCD47AFC127C80B4C968D21F13F56DC98F09A9FDFB5D5FFD6745F2B709199D3
Previous signature
8827A7746B47339BAB46C72DD996885E8FE8C0663871B1CC17DCDDDD87035FFA816D8E0D3BA9317204AE4C5454C0C4B36D8DB22D6C719EA8ADCC586805249D0D
Origin signature
3045022100BCF5551551AA7D1AD348FC25A4688BCAA8960A06A9B5F216A8894D6AE5513A6B02206FFBF92F98C61355181ABD119DB1B8FEB7149228C753A4A6BA7ED42A7F1B38F7
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
004CF2DCFD6FF5631C622547DC52BC0FA07D3412F815865CF17067B1E4BDBA9FC3
Coordinator signature
613112C8F54FC5915F42A3C3E550E04FDA14DFC6F7E7FBF3914ECDA86DE4073BBC10CE483CC8D8191448E0328998D5013497CFC3ACB6BF73F3C33FECBEB2110C
Validator #1 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #1 signature
3048538A4DC963C19C512CCCC4A8931216A0516BD4FAC6F50FCFDC546AE858A8576C72EA40B8DC80A9032C2AFB23D75291DA9981A0E6892F551C01F2AAA7EE00
Validator #2 public key
00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947
Validator #2 signature
B1BDF89923D8421085E350F76CE1BB8BB5A49FC55FC50F570B220CB1DAAA25294EE3C7BB9E61EDC50C8A4C95894E84C60A04273145D32B53EF2387061487E20A