Type
CONTRACT
Validation date
2023-11-08 13:44:05 UTC
Fee
0 UCO

Code (953 B)

  @version 1

# Automate the refunding after the given timestamp
actions triggered_by: datetime, at: 1699457940 do
  Contract.set_type "transfer"
  # Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 9.95e-4, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1

  Contract.set_code ""
end

condition triggered_by: transaction, on: refund(), as: [
  timestamp: timestamp >= 1699457940
]

actions triggered_by: transaction, on: refund() do
  Contract.set_type "transfer"
  # Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 9.95e-4, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1

  Contract.set_code ""
end

condition triggered_by: transaction, on: reveal_secret(secret), as: [
  content: Crypto.hash(String.to_hex(secret)) == 0x1AF7F637FC94C11D12B0C1F27705653FEA86BBCA0E9DFCAB170C22AF0761B228,
  address: (
    valid? = false

    abi_data = Evm.abi_encode("status()")
    tx = [to: "0xec5d6b5689d5d7fa514ead02f8ad6e552e759f03", 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("https://polygon-mumbai.infura.io/v3/3a7a2dbdbec046a4961550ddf8c7d78a", "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: 0x00008DD40CD42287A3C8282065F5BCA7259AC7014CD73109B570E946A977687C7BD0, amount: 9.9202e-4, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 2.98e-6, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1

  Contract.set_code ""
end

Content (0 B)

State (0 B)

Movements (0)

Ownerships (1)

  • Secret shared with 1 key

    Encoded secret

    4C1D1D9B11B32EB89DE4E5442598DB96E1882EA64F6347B09E3704D187F141856D29B4E19ED1040492D1B67504C7CA56ACD746C2A37B29F76627E0BC

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Proofs and signatures

Previous public key

0001FC909AD6607FD33CE94E30CE3691642965E1F1A49B7A6B14B1F44C8432B27947

Previous signature

5CA5A52D44BFF85E61BFDC1F57712940106C3FDC91656E456442F638AD9E86B49951FFACFDDBD544C1A9CA693E8E71BF4AFB598AEEFE3ECA2D5835BEE9C8E505

Origin signature

3045022100AA588E460E0D19B74CB2A58290C1F822AC08F63E5F4F693144C5CF05666003C80220377885D2B913E57CC9E36D60EDE87FD9B06DD6D7B6DF3B1252E427BE080B26CD

Proof of work

010204D6052E0C6CA9244CDE5F3D664296BDFBA0090B330404C3C16B098758F27965DFEC0D3F25D1365F389C2B6C516195552F8779DEE0796C8C33F1A9C0404F4E3381

Proof of integrity

0019F1AC55E8F45888809BD95DCEE2D94D372033A107A3D56F962C6E563D252187

Coordinator signature

CB92E169E3E86C12972C7303988FB281C3D28C28361BE532C71FD3D03E9C4CFE405FC1157D41178D31D1AF01BC9C640E7B872DB1A5AE415B257C246D8B23F00B

Validator #1 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #1 signature

FFFA46CC2E9796D0CB1A9D796342967F488B2381B8B672309765D546A1C5D8D2C197CA0107D704A8B0944C761C08C52D82001E9AD39FEB45874A118E3FCF4B05

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

70DC73148F84782CA7A79DF031EF3ABA0533830F3C92495A8A204D59BA33A77A6078BA0B9BC514654B01A5E41129D9F6273BD6AEAC82FACC6D187CA32882FC04