Type
CONTRACT
Validation date
2023-12-08 14:42:19 UTC
Fee
0.48757623 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: 1702053660 do
    Contract.set_type "transfer"
    # Send back UCO to bridge pool
  Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 199

    Contract.set_code ""
  end

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

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

    Contract.set_code ""
  end

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

    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

    5BC45B7F632BCD709E6CC03845AD3EED481D10603589A814DB0C4204C4399BEBA2A5C7E2BE8B70BBA78B798590E487DF1FCB30924EEB733E35D14987

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001B7C3C6C02EBFAF85B85CBFEAC520B991994042F909D08C8F0B7A97EAB1502578

Previous signature

BAFD93FC9EC1A6050E2AC991C093B5CD00B566A70CBFB0556F0EB385A581B3FC0CA1EDDCBEDB7B14A7D36895AB23C2BE387CEBD4C0902F507701CA94BEABE203

Origin signature

3045022100879049482B25FF8D3965D3C6A85D342260AE9D7C95FFE4D33BE734CF0CE2E4DF022059DB0664ACD3F47EB22460CABCC7C4FEB6241B9270AB99FA410F3DCC7CE1890E

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

0091C513E64B88E9C6A9D54F87D4144290F23A9D882A82D6FDD0A5720BDBA8C60A

Coordinator signature

440B559FC2D24934798876FF189A3BDB4B51EDDBCC830BC10B497B39F201BA0B806F61BC1CC85ABA5A18B210CF9FD82753DC6EDA967C5633207C48E279C21C08

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

DCD3D1C2C557FCCFC0EB23FB2C0A14D911F3B89D83BD74921B247627E0E13EE77A92859473533FDA05471DB87B5D80A1B5B8F50DA702E04597578F4DA4043C0B

Validator #2 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #2 signature

4B56F5C21C7688543CA58152BF02D27186FD11437829370CF7D235FCF811B023785A817EF023DDCE977444AF093EF12F205DBB41586C4CAE92D93833AC676A0F