Type
CONTRACT
Validation date
2023-11-29 14:39:07 UTC
Fee
0 UCO

Code (944 B)

  @version 1

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

  Contract.set_code ""
end

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

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: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4

  Contract.set_code ""
end

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

    abi_data = Evm.abi_encode("status()")
    tx = [to: "0xfda56c8ff44df62f686969755270c2b8ef9322e5", 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://sepolia.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: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 2.985e-4, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4

  Contract.set_code ""
end

Content (0 B)

State (0 B)

Movements (0)

Ownerships (1)

  • Secret shared with 1 key

    Encoded secret

    D4714DDCAEB2124E479A8F208B79315E7E19F64D8381DDD64E12F04D1085A8DFBC87ADCCB244234C6ABA057F38B0D78EFDDE22DC3D70262EC45DED04

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Proofs and signatures

Previous public key

0001A006385E8A85B801DEF04DEF8EF7C418532DB3FF763EB75F7D1DC036ADFE8C47

Previous signature

8AE54EE9E0111CDEB6D527EE58379422C31C2ADCAD07F6DB6A38C6E9D36E60F018A50CED094F590929FBF7A77243C34523345E593567DE4748CC272012F95908

Origin signature

304502201252809BD7E61EAA820E3BC40BFD04696B89CF1BECD0EB9BBAD1AC76A7E4017D022100E1E2B4EE2A3749F1D68879E39CA6A18D367CE21A7CED6F16E52C0143DAF77600

Proof of work

010204E9BB401A767B0C92D5DB139379AAB18E1B449B455F49E3A44F3466B2D38E59F0516B79493A528A95E5A74CF46F79CF12DEB73293458F6A4403D2B3E57D697347

Proof of integrity

006EC47A7F478B62306948E83701EE1273463F5B3283F6824B5250F8D870349361

Coordinator signature

C87D8D6351121525923D594174D5549549338F500535A774730B07D717401E3600761CB7E3D50C5E18CA212D19CDA0F56C864301D25FD0B13AA5CACF9501B704

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

3CCB8D77838FB3C73FF2B6591DE25F713613B1454A961F778F025AA3F24111E2ABFA3A31F6F617F8A65CC2AD3B19ED399632624DC86FBAFE887E60D1E1DB2708

Validator #2 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #2 signature

10498130D8622849BB9A6F8E52CD1AB95C58328F90462E1EB9C6B639F31457BA9E183C7C96009BFA72ADFF1AC9D53FB5C04A7E5045DB7563C2F30D06F165620E