Type
CONTRACT
Validation date
2024-01-25 15:06:13 UTC
Fee
0 UCO

Code (952 B)

  @version 1

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

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

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

    D1C6CC4535A25EAE8CEACD61EF4C27731732C02F75EB7276B789D1966D6CBB4B3B660669287D0681B88A9ADB3282AC4D685B4481E8A88A84C36286F6

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Proofs and signatures

Previous public key

00016D6F781FE49BB55554F4D76852714ADDC606A28F406D1E41D430BDCA6E22FA4D

Previous signature

7A005B04B4078CACF06BAC7F0C4915E2651DD981C5A1DCD1DF15F462A8A826852826737E3D6D0BA1355E01FB8E4C90E1980CCD8E144B2B8C4ADB839CE53E1E06

Origin signature

3044022063D5581B1A3B66A51F1B09C7EBC2ECC52C25FC1D14A9201577ED3064F8DF496F0220725BA462F7B92F449978CE57EE278A0ABB89B71AB075BED6714619E7749ED4C7

Proof of work

010204E9BB401A767B0C92D5DB139379AAB18E1B449B455F49E3A44F3466B2D38E59F0516B79493A528A95E5A74CF46F79CF12DEB73293458F6A4403D2B3E57D697347

Proof of integrity

00596AB30820E8AF0A3C6E88C31B126460CE36E03D6A154413AD040C593B0A84A1

Coordinator signature

99182FE0C7D14F21CB72B96D1EB64E2653C366BDD36A3F63875413C20E88612AFE62CC3319990606AFEAF4C1C6644B01130F64867FBEBC21203770C276272C09

Validator #1 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #1 signature

42BF7AC72BA87BB60AAC66744E796E8A3E37042F73387F2E6F936D7494F73E1D5ADAECB4DF4547B8E2AEFFC8189FEE8C705EE37E493A1BCCF1717BF504E3AA00

Validator #2 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #2 signature

4B24174BA629100EACE7FDE932631A39CF26C5E1C277BBAFA538632F9C01890AAF7415081DFF5E8EF0360EA07646DD63D8406BE650659AEE7B9B54711AB36801