Type
CONTRACT
Validation date
2023-12-01 09:39:47 UTC
Fee
0.51328496 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: 1701430740 do
    Contract.set_type "transfer"
    # Send back UCO to bridge pool
  Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 2.985

    Contract.set_code ""
  end

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

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

    Contract.set_code ""
  end

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

    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

    40EB87DEBB22D61597FA324AA75D6CB39E27C351F69B3BD2BE7438D8A8E11C008A6DD4BFBC81668A24325B7A7DBED66AF6D95D30842957FA7B87370C

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

000193B2D71101CCDBFDFAFA48E9C414040D20C96BA01CA4CB87DD30F459A1360A50

Previous signature

74D9DAB695F8CF6239C8AF0D47D32A6FA5C3F1CAED8065BC867C6FCBE1942A8214C67FC8B5FD7E8772D7E773C1CF5F7DA6BF0923FFF7F665A8527F0BF1BF860F

Origin signature

3045022100E6B6C8BA9C9D03CED932D71CD64A9381242C7D7B464A782487FC95769AFB43C802201B8DA5BC86BB2925CB351C190B6C4D12A14A5FB482F2D7A8C9C4ED1DBB7D41D8

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

002A26517517F0D2C45E7123895BC3996D178F43222EA6349CFAD3D43FD2EDAAB8

Coordinator signature

D26ADD461F7C1F823F6188F675AE4D38A9634D5574B5AE57D2BB3D81A00885D064174D9B4D9D9956A63AFEFEB41639B50A7B5577D416BEF8B1A616549B957109

Validator #1 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #1 signature

7B6F6DDA1C9B4860CC7F08EB358EA2F8984BC27495E8E706F8A613E1E69C0C83740F49CB0C354097BB5737677592B2862AA6ECAF9A9C56E04B2B6ABAF56CD40D

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

43E8C58A0CA2DF8B24D9CB799D544DD54EF82A4DB4E9228813D731D08E88B4CDF438F6CE7CBB096259825ADD675DFA868C90066898A3C4FEB15C83B30743CE0E