Type
CONTRACT
Validation date
2023-12-01 00:27:15 UTC
Fee
0.51141915 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: 1701397560 do
    Contract.set_type "transfer"
    # Send back UCO to bridge pool
  Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 9.92015

    Contract.set_code ""
  end

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

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

    Contract.set_code ""
  end

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

    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

    6CFA8EA44B040B088A1E750D24B05B2E972FFF5800D47EA2DD596736CCAD3AA61AF9E00FD9FAD8CDFF1DE66625800D8490991DB84DBB3D35B99686D7

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00010CBC69DEEE292803C14AE418C300D873A05130F26E7B255F3CA6E23264093C5A

Previous signature

E626C49605570A1F43B70C54E984CDD715817D6738695FDFA2F17FE74379A7F1460F5A0B36E60FEE138BF66DE05A31A958C884AD0626F7D006117E01E9126F0D

Origin signature

3045022100AB9B27FB0015C32503451AAA7FCEC315AAF13855D1673B38209E2D6A46F2502B02206B1029F4244DF611DF77962BAF3A27CC186AE306F93BAD3EE3669D3973516E1D

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00FCCC628CFDB493743F0E75F40BCB7A569F28747DDD82ED996EC4C6E0F33DE40E

Coordinator signature

B18DC557131AB3F8E4727290436F7AC7D10AF25BDEC990F9BA05155C12430478D1491274E24A0CDDF72043E79DE9F3DA3F77EF63387317225A0EB6C18955AB0A

Validator #1 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #1 signature

B737AA62DDE2E8BFDE03E245BA8C844C273C0DC4538E9B6900BD3209CB7E8C1E35FEF716D0858E7D3A26987E8F27C322E4D4EE8F0694C1D123DB35375883360E

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

C301C3CE6110302D942852DC6A83F4B84ACE9EFC93F1ED8345EFBBEBFEB9201C24EB7B17049CBC67F409CAFCC8B606B167CE4E77CCA5BDBB34162D17BB48080D