Type
CONTRACT
Validation date
2023-12-09 16:03:05 UTC
Fee
0 UCO

Code (951 B)

  @version 1

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

  Contract.set_code ""
end

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

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

  Contract.set_code ""
end

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

    abi_data = Evm.abi_encode("status()")
    tx = [to: "0x6535ed936cbd74ff98ede606f4d43c5c0214e9f3", 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: 0x000066062AE51C8EDDB115B895B4917CF9A25F20A0CDAEEDCFC62085AB197F6B48FC, amount: 0.992015, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.002985, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1

  Contract.set_code ""
end

Content (0 B)

State (0 B)

Movements (0)

Ownerships (1)

  • Secret shared with 1 key

    Encoded secret

    09E1482EEF7C23354C5FF7C140C3607767B803E6EB39F5B1CE19F108CD2C7235D63E8287F21432BA090946AFEF377ED6FF99E3646B974A3C7867BF18

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Proofs and signatures

Previous public key

0001D8FEF685A60DF75D20CB9B1839DB0AA128609FC1135FAF21A721DB00C597399B

Previous signature

78EF91A2C47D80E0061B671F45AEF19D971D9CCDF602C52E11279818A022D2FC034E551F22E18ACD1FFE5BBF8C889408101D7F6909E0854A41512DE1D78CCB07

Origin signature

3045022100CCAC9365ECE833BA812D030C7C9D5A8999D48F70DDB228400A34DD9F1347D99B02205CC4A7A4AD39BC0802B91030366B63D879F726CB98D41D92B2BCD4591F1A42C0

Proof of work

01010484B78F4110D8E9D6FBEC72759895CC9D4532177314FBAA8B07BC525FC1AF48F150EFBF104B1819106B8E3563CD0E1FAAE5325F8FCFE58FF744C35F47669D2704

Proof of integrity

00CBBB5E60BC1FCF6D2B9CDE0B130C6A098034E5FF28178062810DBF487E6EE865

Coordinator signature

C4D2DC93A083FE790A5D34A9C175B84D9BF9ED583767B71EAD5BD7BDB2969B2215B8FAF677C287CE1B83805079B6CFF53BEAAEDFB9476B7343069280A2984F02

Validator #1 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #1 signature

BF8FB2A0E1A8C0BB1D7E512686023EF64763C4F1E7D88E49365CA31406DA546FDC13F23A6941A5228D8292F14FEC01F4099718730872CADA8A72A2B63E56500C

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

0999FA5036CA475CB725DC29D13A0F4CFB0CFAF99BD21170A38F252AF8BFE3285ACC0936A29DF2598781D0A4419AB5300F309DD4820C0643D30A4D8A638DC704