Type
CONTRACT
Validation date
2023-11-08 13:35:34 UTC
Fee
0.61554319 UCO

Code (1.06 KB)

@version 1

condition triggered_by: transaction, on: provision(_evm_contract, _url), as: [
previous_public_key: (
   # Transaction is not yet validated so we need to use previous address
  # to get the genesis address
  previous_address = Chain.get_previous_address()
  Chain.get_genesis_address(previous_address) == 0x00008DD22E7496E86901E9B276A1BE6F9512EB09980CC04C7B76495EF37D5666A709
 )
]

actions triggered_by: transaction, on: provision(evm_contract, url) do
  next_code = """
    @version 1

  # Automate the refunding after the given timestamp
  actions triggered_by: datetime, at: 1699457460 do
    Contract.set_type "transfer"
    # Burn the non withdrawed tokens
  Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 9.95e-4, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827

    Contract.set_code ""
  end

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

  actions triggered_by: transaction, on: refund() do
    Contract.set_type "transfer"
    # Burn the non withdrawed tokens
  Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 9.95e-4, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827

    Contract.set_code ""
  end

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

      abi_data = Evm.abi_encode("status()")
      tx = [to: "#{evm_contract}", 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("#{url}", "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: 0x00008DD40CD42287A3C8282065F5BCA7259AC7014CD73109B570E946A977687C7BD0, amount: 9.9202e-4, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
  Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 2.98e-6, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827

    Contract.set_code ""
  end

  """

  Contract.set_code next_code
end

Content (0 B)

State (0 B)

Movements (0)

Ownerships (1)

  • Secret shared with 1 key

    Encoded secret

    5DFABD5F55B4D84624A39124AFEBDB61D461705AD4E6E1D945DDA1F2309CCF6C03F6B7A73264D01476ED2F4F8672FA40004D08DC442070E52F141A6F

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00018399963F77EB9B95F44F0C9AA29AA382DE8186F99D5264A55F4D42BB55EB489E

Previous signature

D7319AC0DC50EBB3553623D72ECEB3EA0DCFEB3D5FAC9D230A1FE561907FB0E25DFC1614160989747EB5A3486018A2F9850D8BF1A38CA3161F10F38218621E05

Origin signature

304402200DF200C10294EF4E5C72F1B0C4E5787B225C8F9745EA90C8A97CAEAA4E5D855E022041EE6BE197CCAB5E445C6A51D8C43590E6699CDC07B069913C64A8B41B0CAB01

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

001BEBFC0BA1822B4E51653169239BE1F5E5974A3FAA9C2A5E452E84D5D8615841

Coordinator signature

8B0E64D4CD79BE53F5613AF58DF3182F7775C436A1A64014004FD8B54CBA9E2F8507B0245BBA725DC7DBCBDCB5C68104BDD159BB4CA9DEF5BC77B3901F694009

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

FA6AF51A047F992A725D41EE98DFEEC561657965A84DD0BBA30F82A42461134EE0FC3BBBD873328AEAEEA5D738BF5962A393F4B403D739DC865A6D35B5D35F0A

Validator #2 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #2 signature

2E0648362FF7878D21F9DAADDC2D05964C60521963F512FA911193E83BD4F5DAA9900FEEFD8DF85C201E5CAF16E053E20F3E47FD0200964B43C7F71AD0E9940E