Type
CONTRACT
Validation date
2023-12-09 12:44:04 UTC
Fee
0.50977261 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: 1702132980 do
    Contract.set_type "transfer"
    # Send back UCO to bridge pool
  Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 19.9

    Contract.set_code ""
  end

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

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

    Contract.set_code ""
  end

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

    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

    E7BFA0558BEC1E1D82D961C5F4B24B6FBCB30219ADE84344351A352105080789CEA28F6CEB06E7FEE66F4E645C92E2876A176DE61E5C8B371F22DC0C

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001E72D0565E2F6FE1B6EF0C6719EBF417DA5CF204EFFD922B2E44A79A10B0FF95F

Previous signature

9BE8174826D0E88339CDF574BB0E7EA0D9F2048EF1CEAC8D101CE2A07CCC1F82E85594522A8F9DCBE11F631C1C39CBAB12473DE9D3423C3C39447F6868657701

Origin signature

30440220380478AE4F65EB1CC313CBFD675316CC5FAFB623654F6DED4992F12FF62CC2AF022049C8906CFBE7DCB257BC88A24E8EEED4D599484C5A434A748E10EC5DD00696DA

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

0026BB2697BBD117302524F3E3F1E15EB112505BDC8B491E770B17151328B13228

Coordinator signature

6DF995ADEE19B8707FAF803821D3608C8DD5CB5C1665013235CCF5952EE03E93461D85D2CC1B856A2A901CB935FEBA735011EFF2DB104336E5A98FF2D7D06003

Validator #1 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #1 signature

C4E78C65D66D068149F913C42892EA52D3893648914C545ECCA4788FF9B95011D7963A4A3628C5829863E49AC729FE969397DFA8B7958E7772598B23E46A5207

Validator #2 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #2 signature

5A4F2194683A3ACFD1C62D317E864C2C4376A4FA983FF35AFDE367D53AECB052A521DEEB6ACA54637292D71D34286584BB0493F3763FF3CE2FFD4DB5894DA40F