Type
CONTRACT
Validation date
2023-12-14 04:50:30 UTC
Fee
0.53693524 UCO

Code (1.01 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: 1702536540 do
    Contract.set_type "transfer"
    # Send back UCO to bridge pool
  Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 0.995

    Contract.set_code ""
  end

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

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

    Contract.set_code ""
  end

  condition triggered_by: transaction, on: reveal_secret(secret), as: [
    content: Crypto.hash(String.to_hex(secret)) == 0xAC788F4CA955E7C1B68BFE762118AAA9F79566E468080D961D1BB1F394FBA39E,
    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: 0x00005A2A9F6A89A632B5E8E9F07D0BD4D2C6B054EE82EC98DFCEEC187B124147E354, amount: 0.992015
  Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.002985

    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

    43819C1D076668A7B88B233B65260A35D3BA25DFCA20919620E0350D679A1539F229CC8D838D23AC6FBB880054D3F98F6D39FA5882FE2CB9F8E0093D

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001E45E653E88CA3A64F9FECD22E8418C7A800BAB28F399D00ADEBF6AFC6AF8FEAD

Previous signature

9B79CEE961DDB5AA6CA472CB82F630829252D5AAC985546F55FBD4AD48A4C52C8243995C9CD2548AE5D8A6B73DB75A6E805E206B609045F28824C61B35E7B509

Origin signature

304402206304B61A4B40BAD14315BCBA05910E35A76C603698C7FE0F620F1536DEB0BB4C022017F52F3373D9A75F8F2F4E0C7C235EE2D0B0FE90247693A1B3427FA982088690

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

002C26A83396C50BA1610504B94B0D848544AC7095A4F13B6690BCAF0FA10C64F2

Coordinator signature

AC6ED812757B4FBEA0ECA76F58DA4F00DFE991962B45C2095465AEC1D26F8CDA460CBA49611FFE85F35CBED8324D5279CBFAE297F60AF334DE37145DBA242D09

Validator #1 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #1 signature

4F88A578B7CD9545B597733A55896573E6EE6B39304E24C1B461C81998A47AECBDC444D71FC5E8A47BAD689E19C31552727E615FE6EACE7EBF201BE50F60E206

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

3A6BEF22BC0BFF4A1940CD01CA4450764B642EA60A7627F57181C47207AA098E7288E6BBD82D6763929026883523CBBD1F4C0CB96FF5CB2074DE6C679EEB0009