Type
CONTRACT
Validation date
2023-11-22 12:16:53 UTC
Fee
0 UCO

Code (952 B)

  @version 1

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

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

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

    BF5ADB1F9A37DB51944DBDC1ED039B46C766B527E231A7CE0FD2D14BBC767FC4097AB0865CB03D7FA6243A5C786B185907C420F5AD1CDDCB08C2A259

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Proofs and signatures

Previous public key

00016D9CBD41BFDC8A83427B1BE15F25D08FE92B3B4C81249ECF7EFD86F6DB6755BA

Previous signature

4D50811E3EFCC824EC2A2D07D4E09B64727236877B16F3EB3584135B8DBCE216EFB919ABC20D9FA719ABD05639497A488CD23F591C5026434EF7F8E704FA1B06

Origin signature

3045022100E45D592587978D6F226CA4DF9DFF9AC1E288C6BE1E2152AC2CBC45B74497C0BF02204F2362195B5A03F2C8AF876733C5682669E2A776F35F2D2259AFA88EF69810E3

Proof of work

010104AB672F1E69B064D192819F1797C1926F158DBA8F3924AC732B4C4D70D0C8EA0A0D6506E5896C9C2524D2BE26CB5016287E1816A597C408008BA36FCB154A7765

Proof of integrity

00E63C52329D82DEF024D0724AF3B681740A139601E2C6308495D4FFD472510D9B

Coordinator signature

CE6551DA4F89E6FE7FAA13EBC000DE40A8ED0C80319F0837A4C6E5178F2B4026FFA1DF0C8DB88CB68966501891B71924FD4268AD7A1B2986108CE5E44BF9200D

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

2017F6F01520FA983C37B0CBBBE252BFD54A39272A06A1F2411AAFD1647EB292E357B4FB1CBD1CFB16C3E8B3F8FAF0B2DCD8C4C67034583C9CF7979050832F06

Validator #2 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #2 signature

36A520B9100352383A1EE729C898B7C310C9762297A63597B0F2CDACE8800D22ECEE78028CF4809FBCC416B5146EEFD0B057799BEAD2F3A83736856EF4056B0B