Type
CONTRACT
Validation date
2023-11-15 16:23:58 UTC
Fee
0.42760256 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: 1700072580 do
    Contract.set_type "transfer"
    # Send back UCO to bridge pool
  Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 4.975

    Contract.set_code ""
  end

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

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

    Contract.set_code ""
  end

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

    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

    4B9DE386AF497F7B28A382B777500B9D6AC37F9FDCC1056744D480538090EF46B9DCA484AE5D5B771815819266CB705D68CF1581F013B76338680BE9

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001D5378913E60D237D80A5EE4AAEF2CEF270839A675F062596386EFB1311F60AF5

Previous signature

58157E079E030D794D3B7BE0078DB2D796088BA759A322C2C49AEB34B344FDD29B775C9D90506FCF59763FEA722FFE8659E375C49ED1E6392B2606E1C004EC05

Origin signature

304402202561798CB53584B62D6D3850487AA397333B9959612A8575B50FAA26EA9F5AD00220331B10BD22EAE9F1D4F4F8554AD64497B210E68B8B92E86FA62F21244C950A7B

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00864FC3F87DA32B515E24691188958EC7515C2B13B058C4E45B6A334B1C2AA1F7

Coordinator signature

194BB5387733F85FF7FB1684F299C95774F9E1EA8420FC304B87DCD48EC2B72854CB8E6797F1B6AE5CFFCFCB63840F206281B3767FCA7C8DF05AC1B4C5D31C0B

Validator #1 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #1 signature

9B2EABBA540A1887F92DB41307FEECCA25A5A1887EDA1FCA8555DCB798799AC3D11E2C1F70AE5D6E61DC02BF5C2ABC8C57E0EECD789A7455DD12EB307309D90F

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

452AC2DB60ADFE2D87F85614FCC1E61F76F63A1968C37DC68EADF931BFD6C127DD617B7F61A3B1CB5081D4603598D4E42189EF923A2F6DF0E24CF411DB74AD00