Type
CONTRACT
Validation date
2023-10-26 08:26:54 UTC
Fee
0.93569082 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) == 0x0000072E418B60C6DABD272BC2728B17B352B8104F068D11365D50134F96A4199609
 )
]

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: 1698315960 do
    Contract.set_type "transfer"
    # Burn the non withdrawed tokens
  Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.004975, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1

    Contract.set_code ""
  end

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

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

    Contract.set_code ""
  end

  condition triggered_by: transaction, on: reveal_secret(secret), as: [
    content: Crypto.hash(String.to_hex(secret)) == 0xBA7FFD1504D0DF26A31EA68C24411DE021C877842FC8205376629E0C7AA3D86D,
    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: 0x0000CB2A9F08F4D17280DFDE1E2CEB0830ECECE5E2469EB81E94713C16F37777A5C4, amount: 0.00496008, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
  Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 1.492e-5, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1

    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

    7C138C3F67F231A357664293CE559ADDF6EC0A41FCAEB3A4870DAFCC6E558FE1D55EFD5BB01F9A3A00CE93BCB5FB798B0D6D7B75287B7CE58BBE7205

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001D052B7B314CF2CDB9868578446192394C992F51F21BDF6C42D0D95A5399C1196

Previous signature

1380B9D5AB98F82256308298AF06F8977411A4B6B3970DE0CD4880977E8E1E8F0953B2AF2C3CAC7235F910598CE8EC1A962B44B6C4904EA9D7F19BA607793503

Origin signature

3045022100D1A3D30DFB11470F4D431CF58A0E7E69A612B2CB12FC97C6116126D4CCD6559C022023852AF8472B8A1BB7DA89D36D11E8CF92159F06EE7246BEEC5C92ECDDB2561E

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

006EEDE449E7A77D062840352BE45D766C24669A5C6B5F0546218F89AF513E0CF2

Coordinator signature

2FD3941F135F7BA289E0F2A0D2BC95617C9A36BDF09E76D60C48C2D49F870C123602093E41215D7EEF0117BF389C1E645627D80D07C2B0B14CB85277CCC87900

Validator #1 public key

00018A312AFA617E98B343D09AD2E73F0AB661DB0A59FB986D5DB8CE7664E14C25FC

Validator #1 signature

6A7C698D2E73E3A9EFC47CE37E1A06B5C5BA1AD4F07F8F0F20116900A4F41F3F2C8860449B7340E4D5C393CC111B6F98205A8786770E6B04ECB0BAAF59C5AB0B

Validator #2 public key

0001500FBE298B79FFBDD5CCA1798F30FD88A53D26EC39DE5DDE1F4137B032A4BC34

Validator #2 signature

4F4BE4AB61CB76E18F7D49FB260484E74E9A3C1ABF77FE9F0B2254B3394A38BC5B6B02CADEDC54DE2945809674330C6FB720FBDACF453E6F5E784273EEDA4E03