Type
CONTRACT
Validation date
2023-12-03 04:06:48 UTC
Fee
0 UCO

Code (952 B)

  @version 1

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

  Contract.set_code ""
end

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

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

  Contract.set_code ""
end

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

    abi_data = Evm.abi_encode("status()")
    tx = [to: "0xe93a673cbcf819e4869ecaa4e19c748467de0971", 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: 0x00009593AABE5D416FF4944E6C4C7FC0646A1DB894C5B5DFC774418F093034410B0B, amount: 0.198403, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 5.97e-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

    87277FE01468AD4EC166866F07EAA92CF51AA4A3366720A0A0F0E371E77B96F13F6BA1675E90FE2347BE491CB81760DA783A4901494E2178E7A900BE

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Proofs and signatures

Previous public key

000160AE35AA3C26BB713C1E587932B5108E4FE6ED788DD2F37F1C77016DD756C08A

Previous signature

3252E291FA16E4B6B1C4C8ADA030EBBED7030054B9427EECA42B8606F6241CBAC5B503B54A7D0B32700E6DC7DFEC7532CE69C9CB6709FC49AC357808B99A6F0D

Origin signature

3045022100EB61D650740959C81A7978EB851D5B62F534957DAE8F88E41E861483613563A20220139C9DD597D496D0D06C5EA440BF6B51DEAF17A3EB9EE1B1C6A0844F2D06ABD0

Proof of work

0101046C39D56B717142B6EE14B0F8B2561ECA458F3D2D12C9977D613F78829419063211F9C21F7BB0D56B6523040A8156BE22B6E9D6332B88ED882574D12AE32F7A45

Proof of integrity

0000A2443B210AD58D816DA5F0A0FC4C0B7C6840C27DE885CDF6E8DD9ED89A0EC6

Coordinator signature

447F25C995821B36249392C246CB8080616574C46BE7C34F120BCBCB3818676BB2C5C8D36E6F1F1EBB56C9D267C107C0A755D0BBBB2D99ED2C17D10B1613CA0E

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

BC1CD08CDCDD775C30BD9018404F59A79BC216017866199186F77512AC1E2847983A87A95704390EEC56DC1F5F25883319C2BFC89387C4B5FEC2C37F68B6CF0C

Validator #2 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #2 signature

1C40F5868F4E89ADE69ACA8D236253B32FE8799C02A16860A804CF38D48DE44DE4876FED5664ABC08A981458C5698491199A531384F3CEF3FA497EA4E63B6A03