Type
CONTRACT
Validation date
2023-11-14 20:35:42 UTC
Fee
0 UCO

Code (953 B)

  @version 1

# Automate the refunding after the given timestamp
actions triggered_by: datetime, at: 1700001300 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 >= 1700001300
]

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)) == 0xBF7191C1FC98568EF02A10FDDDB9379B7442BD1FDFD4B52EA91849E9D0CA6EF8,
  address: (
    valid? = false

    abi_data = Evm.abi_encode("status()")
    tx = [to: "0x05b29aa844bf2ddffe669b9f3fccb8e1c3724e03", 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: 0x00001675BECDA24450FAD82114A15B58567979E8E7AEA1CFFC54CE8C1779513EA2AF, 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

    D7B5343D1398A0D0C4E2E58A25F85816623D15643A5A87C56F9EAE0E07958AF5FC9F10AB9EA79238F7478335A75771E8D95BF39E7397EB522F2DFFED

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Proofs and signatures

Previous public key

00014C3453AB2CC1AF71EE548BB03A81ED02A65ED0E96132C9F3443CF47D1667CDBD

Previous signature

C265D462FE2BC4493E0FB3DAB38B55047ADEE5166D5E335F22B34E56D7EFD769699ABF014D3C22F2C52B98B69F1EA5DBFDE0C31E2C44DA012F8F823775A4C206

Origin signature

3046022100B18258765E00BECB3E79168F53F0B84A8262E4233FA129830B6F202BAD885E69022100BF000D524692E81BC681782FAF513DA1B700186865D113DBF5046E6D7D441D2F

Proof of work

010204892A04DBE05192BCB662689E7E19700F3F7202028EF0A9F20635C4948436ED85A43BA3017281EE97781342DD8F24ED6F583B5FE542830FDB5191A11843A72A61

Proof of integrity

0079E59E919EC074441FFFEE19F86D472A4417DB0CE1C0A6303C565230E359DC04

Coordinator signature

A94EDF4964BE6A08738869E0448E972DCE0834C5FF0CE3AABC04AC3AB423056436F2E9EC6F29BDBF9BD6C9FF81183D1E280BD1D32A8EFE6EEA5F6DF86C31CD00

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

F48C9C2B6D25E2D5C74E9D0742EFB251A31F33DABF96B44C454B6EF2FE073AE11EF31D2FD338B5DBCEE270C54CD011E43C7B9A6760178E91543E871A9237330D

Validator #2 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #2 signature

5D3E6A823D2848657ED90538A4FF5C1F413E6CBE1DBEEE7A9BD3744BF392C5BDED719DEA2AF3244B430481546DF4EFCF33BCB9ABEFB63F2D13BDB9FD00064D01