Type
CONTRACT
Validation date
2023-11-15 15:40:26 UTC
Fee
0.42839621 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: 1700069940 do
    Contract.set_type "transfer"
    # Send back UCO to bridge pool
  Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 39.8

    Contract.set_code ""
  end

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

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

    Contract.set_code ""
  end

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

    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

    EB57C1147B111033652F9C5247F9954993BE200B8CE5BB4CB8B4510A1A2BEFE4F48116D3CA69ED3AE3038EA8FA31D3DB7F430F01647F90F63E754BC3

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00015E4F010E7DAA705A0C129758B7DA8663B008AF3A32AD569CFB0714327CA7E48D

Previous signature

828F97A526ACF36AFC5EB0BCB80327A4E83DE2E81916BDF36ADCA56EC3E799DB71A8AF9E2C6A1ADB8AB57B570E0C9A1D8F6AE09A30F8610D740969EE28B0E200

Origin signature

304402207EBF206A54A5849BEA37357431A8E01C4EA9283905DEDF1F63620890FEEC1FD9022022F2855D45BC7FCEC319BBEE6559B1CCFA3D6F48FFD6978A889B9F4502F04F1C

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

006F3D4B4B5FADD4CFA9B1EC73FCB5B6639D86AF127A91F1254986D292DFBBF4A7

Coordinator signature

5B0F0846184D918FEB6C338912321B8D40350E02F2B3ACD7CC90D77DB8EC69A7E5D7DC05BF82363AAA97F324108A01A0E33BBB4AC149140526909BD46E29CB06

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

6BF3921031F3B8AE980E4EC3C220569D804BB0FF0DA8C2394688097AE5AD2565F04E0A3BA21CED6D1FBB1997A7E4B4A71CF2B6CD6250C104E849DE4E61BFB400

Validator #2 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #2 signature

39F1F877F72A355CD3A4B23B4679537F2BB915A5BD2125325709B9328FCDE810859FBD70B9BFDB8F11B96DB43C52B79A899591E037DADC40854A6A3C5B19B90F