Type
CONTRACT
Validation date
2023-11-13 19:14:16 UTC
Fee
0 UCO

Code (950 B)

  @version 1

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

  Contract.set_code ""
end

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

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: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1

  Contract.set_code ""
end

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

    abi_data = Evm.abi_encode("status()")
    tx = [to: "0x58e155366464907d4e1a2fa9b89c2adfda5fb4f7", 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: 0x000024EFC168359BBE0ABF897270CBFABBFF5784622EA02A463BA2EAF7C5219EAFD7, amount: 0.0992015, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 2.985e-4, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1

  Contract.set_code ""
end

Content (0 B)

State (0 B)

Movements (0)

Ownerships (1)

  • Secret shared with 1 key

    Encoded secret

    50624E0A421DD956FB2B8CA337AE7123A66435045F2CB766F6DF7A036A6098FB35AA5E1557882910006509BA1825D18481121273A76D43898DA13459

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Proofs and signatures

Previous public key

00013269469AB91B0C51180B38DF6FB9CF33EF4B904464C0527B0F462DD3E51A87C0

Previous signature

38DACC7FCBB536315A2C7491C2B3DEDF7B38D52BCDB056DC4879B33CB64FD03F9F3916AB0C5CA37D633F52D16411FE33B4EB389F591BF128C118BD72DEEE6A0D

Origin signature

3045022100C9D5417B2682F1D965ED77734201685328CA48A142980213168D37EB84829B4602205CD8C1199667BCF534DCD0D8A1581D40B2ED3DF8618EFA10DDE24A3F476973BE

Proof of work

010204E9BB401A767B0C92D5DB139379AAB18E1B449B455F49E3A44F3466B2D38E59F0516B79493A528A95E5A74CF46F79CF12DEB73293458F6A4403D2B3E57D697347

Proof of integrity

0004127DF96CB487EE7923DDB419ACC38E6DDBB9733E3BD1D853C408DAFC6D1E9B

Coordinator signature

ACA29498FBCFA35131628E5D8A61761A04D88BC9B70A93DD7AA0EE4D1345253947CE5741EB33D20D6788BF694560963A3205227076589E7E37990CAAE819D208

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

BBE13ACAAAFD81C4FA174CCD1E0BB78AE820257A5797545475A174F454DDC051FCD02C04FE12B520EF2C26A8499E4CF7A45F650B0B1BF76E437388705B8A2C03

Validator #2 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #2 signature

FBD7E293852996B2B69984DE87E5F824C057C3C61FE0E8A5168BF59171BB8D390CEAA0EC421D76504E3A4C5D2148E5CA364AA0E82AA0DA416D5C6FEA4A9E5800