Type
CONTRACT
Validation date
2023-12-01 16:44:36 UTC
Fee
0.52535905 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: 1701456180 do
    Contract.set_type "transfer"
    # Send back UCO to bridge pool
  Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 42.785

    Contract.set_code ""
  end

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

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

    Contract.set_code ""
  end

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

    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

    51621D49D23264F029E146A6202ED7D5C43E212F55F643D97307D2FE8FF31CFB5592CDFB33527C7BC7941E77E7CB6ECE2A65BEEC533B85A545CFB3B4

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

000132A052CDB22F23DF1E81DCCA43B784B6705939346C7C3B6E9B50A10D62CF1382

Previous signature

3E696438193B69AFC8D0E61A9BDED844CE35203A9340504F29A634F21569E24FF134C629E5C8B26277DC30D041A5D9189F3EF7929C25C7862A913B7E4B61050A

Origin signature

3045022100E4048AD76C57C5B615E8F1113705135EE3654AC35451D079E3D5E1030F052B0C02207E26948E925FB9BD74D25E0A3B243ADBA854591840101AD5BA45FEE1454DB0EE

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

002ABAD4861D76E1E795A6205A8C72DDF5DBD732846C6641631DBA736F2AD5D73D

Coordinator signature

822F2616790B3339B1EEFCF66AA3EC53A37FDDF67F881276A219FCF43C5BC05861AA1AAC4B527898F745E7414FDE746F61D73FD8A3F0465D5EBBCA1A062A4807

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

C8D23FED1A64CE1251543B2D84F9B680AFA7BB2547FA9491F4D9794A04663EA92A86DB0F2858651F7CA1E28CB6284199005CAE51125CE12689929351CADF200D

Validator #2 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #2 signature

F3F28FDDB89C0634877A835A4774264301C0B0643CBCA7C0B95E01884DB2888DF0C62EA33A790606769F8AFA3B517E116908751BBD47317B9A51C0B3C99EC50D