Type
CONTRACT
Validation date
2023-12-07 06:43:31 UTC
Fee
0.49833615 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: 1701938520 do
    Contract.set_type "transfer"
    # Send back UCO to bridge pool
  Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 2.985

    Contract.set_code ""
  end

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

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

    Contract.set_code ""
  end

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

    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

    4A6AC23C0AF4AC47E3386B3A76798310FC5C802F58C322CD5E5948A173F392D083C2B42BA3EED947659E4C8264643DAE3E0A8545878304BCD3BAC0F9

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001C8B779DA49D26D9F0E64171147B926B6CF1357D8481E791B6548DB612C55871E

Previous signature

72123481A1C2ADF6A0545FE7E1A10C6DDB75D3E7F201B631B82F5CCDAC896B6B63160811BD8654881F3928BDF0C9482D10FFC84C495416CE82356CA43A24C20C

Origin signature

3045022100F4B1F1FADE5C9476DCBCC17468DBFEABCB79A27EB13CFA5936D35145DB8D64360220453FCE1B006F7E9B1EE1C472C1E0FA9CFE5CD040E2595934F2DE723BAB29F939

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00D6E25656FE005354C6A20500050D891069443EB0D62E748A223CDC30771ABAD9

Coordinator signature

7CDCED2FBCBAA1D9168A6398F06BF5690351F40EF2B3F72F7C5C8662413D08E7B807A07F6B6933DF0E166C6864A6D693F02AEA22CF426A9CDDB6D0A758632605

Validator #1 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #1 signature

4FABB4F5932382875B7B95320B46A060518AC837CFC668CEA2D943895DBF39E9E4C31A646F571FC50163ADA6249701900D55B2B779ED041600C44D053F5C7F03

Validator #2 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #2 signature

C4378B391641CA2A557A01C3E8070814F5C66A770B0815BB2BB69DB9AA280942DE7A76D525A3FF65799AF7A0FC96AC71836E95FA90483D0229AD5955E2DFB809