Type
CONTRACT
Validation date
2023-12-07 01:23:53 UTC
Fee
0.49569496 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: 1701919380 do
    Contract.set_type "transfer"
    # Send back UCO to bridge pool
  Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 1.99

    Contract.set_code ""
  end

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

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

    Contract.set_code ""
  end

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

    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

    75BAAC00A7E7D5AD807F0CDD65D4162F9E512BC7EBBCCCBD05EF66626C1D0BA72F2F80282E9D34609C1A9B7AF091A4C7F92731B7D66B20362ABD6D9A

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00015C38F38202AC5880A205AE504392C39A624B519FE8C3018A1E54B59FB61DE4FC

Previous signature

31197AF530AAAF2B8829BEC8C4A8D263F19B44668F871FB2DA1F68757343DA264DE1CB04D97CD8915A11A7DAADC22621F1CA0605ABDA45CAF41174FFE99A6802

Origin signature

30450221008FCD8B2C5D00E0E13072B886DD4238BB7495716995F4C28B077E95EF01148D0F0220475B4BEA622F0D04C298D1F4DBB9E244EB9B33D5F3702A55D2C9AAAD929D98BF

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

006240513307C1116D2A7B5A9C5433EADE0E3958F0DFE95D19AD70CAF3E30FCB03

Coordinator signature

F1E202709A777FCDAFAE730F2158DBAC3FA8A9A5A8C0F4D65B78CA4CC1C204D2788346E968ED7569ECF4361B9C6C27873B2D2800E371A4053DDB3463C9E2E202

Validator #1 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #1 signature

888FB288415F86218562812DDA1B7B0145378E544E68E8BE37F61484A1DA4B82129E10A38DF8864A146F1DF983C3D904E2DD880A2BE971BF6CCAE6AFCF9EE709

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

D1AD19B095F0DE94E526CD61B35F1EA502102F5EA040AC17F79561432ED4F8DED1AD4D503BAA0D9683438D5774C97A1773BEC766FFCD89A90C89F1D3B28C600B