Type
CONTRACT
Validation date
2023-11-30 02:35:43 UTC
Fee
0.51213357 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: 1701318900 do
    Contract.set_type "transfer"
    # Send back UCO to bridge pool
  Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 3.98

    Contract.set_code ""
  end

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

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

    Contract.set_code ""
  end

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

    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

    62D26849D531F2BD33247CCD01B042EC0886221D8FB2A926D1119FE4BA20E7D188C9D06E459D41DE7D4443DFE3CF76D1AB39EDE0C3FBE80F3696306F

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00017E369C71084D524CA45048E6CA7B2C6DD2DD3FC2AF97D5498EA376FDF8511E48

Previous signature

113445981D1D7AB0AACE23AD6D1438F8888AC14E9B9F81B43D88E98AFBD2C265AD0E5CD36DC43BE490E2BC2672156BFDDB41BC1C19111186593083574F9D1303

Origin signature

3044022049134224DBDE0CE8F0D534D97899F924DBDFA22B5614DD5965203225EFD3E18C02203ED36B1F767FC76FD13258E5B6F880F836CC7A97C269FBB60E90B11B3B477489

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

005C3EA271191DB5A7662B7E6DA45567840E1494D621021BE3D2B39DD92A2DC022

Coordinator signature

B8C892919908A9BDFE4B26200EFA27230D7DD5D9302C684207744B50F78F96D566DD63EC137C3CC5D802410BC6707B733D108C8410E886EB817A658E8915A60D

Validator #1 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #1 signature

6F31C4AA7FFBAEA12B0A3969645D130756E0A3BB56F420A7C056D48F94C3D49BBE86614850D46F54A29B68207289E223981AAC6F76C60CE1FE9E0473336C620E

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

0937E2F00A5C807857C3E001675A120629840397A7D0B0A63745744E06A2EBF6B96D828A0DC6D5224D822311B7A1231CA3486FFF7E1C9442AA6D64CDA2F6D503