Type
CONTRACT
Validation date
2023-11-13 19:51:51 UTC
Fee
0.58925516 UCO

Code (1.07 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: 1699912260 do
    Contract.set_type "transfer"
    # Burn the non withdrawed tokens
  Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.09364572, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827

    Contract.set_code ""
  end

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

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

    Contract.set_code ""
  end

  condition triggered_by: transaction, on: reveal_secret(secret), as: [
    content: Crypto.hash(String.to_hex(secret)) == 0x54E03F2132CC98CAD299534BC2514F9864F652D004074FE95D566B2BA2D4A404,
    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: 0x0000A487AD42A5AA666E2021057C89AB92C97513B31EE65DCA76132BEDE148B12843, amount: 0.09336479, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
  Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 2.8093e-4, 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

    388EEF21A727D17971B36079CC31944B74EB15DBBA0DF23BB5877DB4AC6007EDF69216AFEF71E7385DBD7EFE6134AF3A1BD1448C91554215979E24B7

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001EF7C53A527174C720E9D0577290934E55CFB6456AE57F40E8231247362D83424

Previous signature

729E86A11C0AE244FB9261C9594F523C92023F5F9DA04CAB8C427A88FC8776CB399FA28ECB86AE41A6C220DFA1E1FD6BFC45F6C67DF2731D947E71BFA08DF402

Origin signature

304402202229D0DAB3B9B1569F63B6A988C26F09D5F97C78F5B86D503883E49A5CDE5C4E022008847A2858F16E6D26079340EFE080CA3556F126D1A1E071536A2B13FE5DBB82

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

008008E1F0DBF5057745BD5272918E0F3FEC4704CCFE874FE58292D30F575C0861

Coordinator signature

3D9D474659F90DE32ACCAB418A23600784A2DC1F394B390E3D86F62EF9EC0CF61B91BF4468E3CA0043DC815590B7DDF35EA1A240BAF5AF3E7CDB1F74D8B52101

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

C4EA875FBDD6AD6D71685424D9BF3FB745B89709ACF51EF4179F9E9C7AF02DA308514F224509D20F4725F446868296EC1D434C26A438EEC980EE1717D2B69100

Validator #2 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #2 signature

99D02AB13922CE77BAAF38402E36930FBD96FEF7CB9474B8575769331174FE4F32DF066CAA8D24F12CE6A22E5CDE56BF096E4D679FCE01202BDDED60050E150D