@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: 1706378580 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.00995, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1706378580
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.00995, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x551B93DA409266CE0C1BD02D2D95DFA6E70BDED9058E68744B559C6C21699116,
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: 0x00009350ED646798BBEEB8191967710ABB018B1D7D0CA7E3DD4BFC025372E1923AD8, amount: 0.00992015, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 2.985e-5, 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
5FBD58F627689D032582A7D0C890D26B1397C4D4C94D8E1FF8FBCEA15A83923A13AA4BEBC35D0654FFD857369856CD180BE7F20DA7BBB674DC370149
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 000020FC...6BF6request_funds
[ 1706378580, 0.00995, "00009350ed646798bbeeb8191967710abb018b1d7d0ca7e3dd4bfc025372e1923ad8", "551b93da409266ce0c1bd02d2d95dfa6e70bded9058e68744b559c6c21699116", "0x1fd6a7dd5cc22b665d23c8ef1fe0bfbec323f2bb873e12ae4ac23c9cddc5bfe4", "0xf5ae0b478698c3a5663c01974e4c1c03737a71e9", 11155111 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00005BA9...4A39At 2024-01-27 16:04:10 UTCAmount 0.36790713 UCO
Previous public key
0001EAEEFCA30429AF79FA1A9EAD992C62306A10039E937E9D68483B9E2A7E819AE6
Previous signature
B50863EB064958D0F9C01C01AA42DE93F07C140FE76A1282052AC92BF3C246070896C207C136D50F2D567BE0085F2F30F6E736C5A490B59E4122B05480D85E0E
Origin signature
3045022100F73E43F4DAAB4216DA4998F59D48783B9FF6A49B1961A32193959E5B965260D102205478B6D076352DBA225F3BE9569AEB21433AAFFCA1594400DD920DFEEAD2A8B0
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
0046336349E80D91EA971A553B0D4805F3B17797870E6EDD934EAE88980A3AAFE5
Coordinator signature
D7223AAF6877EBB8A52A1DFE15B1988D223739C491AFF23D8D83E1C2B8276DC989BCB36C97F191E9C6260C99E33F398EF87298CC1021455E789D33352F23EA08
Validator #1 public key
00018A312AFA617E98B343D09AD2E73F0AB661DB0A59FB986D5DB8CE7664E14C25FC
Validator #1 signature
8A3CE6921562D5A3B7EF5BFD9DC2EA62746BF690AF76071C80D679D4CA7B350A37BAE08E444868957498F61D9E17E64A8B7AEF7195C5A2E37560FA06EC374402
Validator #2 public key
0001B01EEF96BA7E95FC844D456CE8868F18864519FC9532E1751C2035FD044DD5D0
Validator #2 signature
D4EAC7CCEDF1ABF8559785285D5C7676236FEB2F5D6CAF2A60BCECB37DDE6797A0BAF00409EE5DDBF33F37ECD079EE392CCAEAE889A739A9FF7D9A27A284040F