Type
CONTRACT
Validation date
2023-12-01 08:17:10 UTC
Fee
0.49788748 UCO

Code (1 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) == 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801
 )
]

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: 1701425760 do
    Contract.set_type "transfer"
    # Send back UCO to bridge pool
  Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 18.905

    Contract.set_code ""
  end

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

  actions triggered_by: transaction, on: refund() do
    Contract.set_type "transfer"
    # Send back UCO to bridge pool
  Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 18.905

    Contract.set_code ""
  end

  condition triggered_by: transaction, on: reveal_secret(secret), as: [
    content: Crypto.hash(String.to_hex(secret)) == 0x1565D58DE070B35DDA131042C3E5298DDD6D43E6B8F7FE7158D08D0445FE086C,
    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_uco_transfer to: 0x000006EBF65A8D742B1176B2624E031A76BA2BC7D3284705426E8306C5A92A1FA9C4, amount: 18.848285
  Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.056715

    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

    981ED397EC7F4023E395C5F8790FE2D4343688074FA3EB288DB8A01F237FB806B32D49DD60AE7BE5CF981CA9D656E7CB1AB988E536E90BC5D966C85C

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00010F76555D62AB50B66ED763FB60EBE9E0B16B621416C882397CBDADBE8456903C

Previous signature

CEDD80F3CE1F0EFBF4A7BC1C2DBF749ED65451978578C294F51AB8AB5AC510E52777AC5492B685B82DD30C420530E19FAD73CDF50C59003BD7A0EBC55AEFC30E

Origin signature

3045022100B469088EAC6FEF6B07C9616FF7170FC488DEFDBE7679C7613020B5B6CFE971DA02202C0CEB34E0A36C00D12EB930AD3264AB66862B49F4C104DBE95B308928E85228

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00DC47E011605FB4EAC27004F11646BC69795487714DBA7C35FF7515748F2C8D46

Coordinator signature

007206A38DBFA6EA8A6E1CA00D35EC2D760F63BC21EC57C981385F2E856D552DA2D1218A3A6C0398895774984EB6187F9CEE77271A69C74F084418EAE297760F

Validator #1 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #1 signature

FD92D126A8FA5E2F09C1DD0BA240DDA020C916B96587931A159911D321214E18FC5791CC81EEBE18A6704D5D7AE119D2636B30F208D59A197741E1AB483B6503

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

BBE04930135B52D0E26E612F758EFBED99AD3193E8C012676ABDC56AC20912C7242932BA8264E54689A3EDB382FEC76B80E4B63958287EF01E83717EB021450C