Type
CONTRACT
Validation date
2023-10-21 12:47:05 UTC
Fee
0.61533428 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: 1697899560 do
    Contract.set_type "transfer"
    # Send back UCO to bridge pool
  Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 9.95

    Contract.set_code ""
  end

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

  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.95

    Contract.set_code ""
  end

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

    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

    BDBE44F9C16EAE7293A8B6295377D6A183F5B98C1B928479EBB5CE0EEA018EC7E13C4C69321BB9178D74FB5150F1333B52A96353085A2E3AC5B477D3

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00010A0FA25CB5CCFA0196879B3914E78CA54B3DD8990BE038AFD4ED908FA0F544EB

Previous signature

B645ACB53E3F67207CF550C1D9FE735C95157992DD8B4E139FAF743A888C5C82E57AEBA6322CCDBB7A4A5A4D2A984598770A1993F5B6E5EA0FFA7355A4B4A609

Origin signature

3045022100D4AD8D408FA27073081C8E00BCAFE4BDA8FF86CDAB3E5DE920A0BA7930DFCB210220142B01AEFFE6BE643497EE8CA615D4C93208FDFDF95BB12956EF1D64560965B7

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

0081DC3B65984CBD78ACF0C9C494347C256D22391F4311DA9EAD07748D1D16C9B0

Coordinator signature

1EA25D969647F2031F23CF219A0CB2130FFEB7C71BDBC1458489F3F42BF1973B56E2641DC153FA8AE9A924594DECB22ADED37057018DBD1DDF9C460AD16F4B01

Validator #1 public key

00018A312AFA617E98B343D09AD2E73F0AB661DB0A59FB986D5DB8CE7664E14C25FC

Validator #1 signature

D72FECDB374C646050CBC026F7425E41522B03BDBB85B0032DE2EC3CDB83157304626F7166FC4DE39A51B7F99C0901F8C593E5459C2921BFEE114BD1DC60EF09

Validator #2 public key

0001500FBE298B79FFBDD5CCA1798F30FD88A53D26EC39DE5DDE1F4137B032A4BC34

Validator #2 signature

C68D7CD74114DA6BD8C2E6B8AAAD36B04ABA79DEB60DC537AB3F9051478A0FADA9FAAB7B5C246C36A4D6B57182D3C2D60886F33502D3A91A60F337740D5A6206