Type
CONTRACT
Validation date
2023-11-14 12:19:50 UTC
Fee
0 UCO

Code (952 B)

  @version 1

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

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

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

    7EED7AC54B19FE7D0BC4F6B841871DE441F6E02A97890E8ACD2142F3DCC256E3E2A502BDC3C89676B4C90D6D19A609EB894BC3118C6A4661EE82863B

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Proofs and signatures

Previous public key

0001DB77F6CB87D62EE3597C5BF561D90B13CAF26E1475CB99650839BC2198ED388C

Previous signature

F59D11A8A05256FD0CCF32FBC693FD2BCFB4F7A88796FB205650FBFD506F0A775D829071453265B9095FDEC1EB422E6763B7598ACDFA748AAEC935B04A365F0B

Origin signature

304502202E2E270F3C4BDAEBE1FE94D546DF7781F24A79F164FFFA0AC5043D365F1670E4022100E32B0C6577654FB42696E35888DA7CE1792C2288C46F57C761331F61DE08674A

Proof of work

010204B3B2A53580086B9F36919CF40ABC55904729F78BF43673E216FAC1EB2451DD1E521879C6588F0CB09B150A103A39A73E2816B5ADF51F0721348BA3A66C33023B

Proof of integrity

0020E7C038D500086474D0E349FFB3A2BA01988CE63920ECFE7162FDC904233BD8

Coordinator signature

295A956D7CE22BA90830DDFE1C126E574408200E99907AB79B8CFCF4D6E8ADB3A90CDA86AE0C7B30582998DC53BD912D242622BA1C92AA697A49983627EB1F0B

Validator #1 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #1 signature

818ED9023B61DFCDFC6B0DDA22DA6EC5C5D8FA989D9ECF4F2C77451E04A2358A59907BCC5A32AAAFAF79AEC9B22FA4FF322F79A71D849BD62973D4EA8A34B601

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

6992507E0EB87FC93549A61A50B351C21195B1923AE962E7DAA5DD979B31E48A4717B359F7CB2E0F2C2FD48A26E596255F95B3ECB49A0B051F1B3CEBC1415709