Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write Miden assembly for P2ID and P2IDR scripts #12

Closed
bobbinth opened this issue Dec 26, 2022 · 0 comments
Closed

Write Miden assembly for P2ID and P2IDR scripts #12

bobbinth opened this issue Dec 26, 2022 · 0 comments
Assignees

Comments

@bobbinth
Copy link
Contributor

bobbinth commented Dec 26, 2022

We should define some set of "well-known" scripts which user could use to transfer assets between their accounts. Two of the simplest such scripts could be:

  • Pay to account ID (P2ID).
  • Pay to account ID with recall (P2IDR).

These scripts are described in detail below.

Pay to account ID

This script can be used when a note is intended to deposit all of its assets into a specific account. The pseudocode for this script looks as follows:

begin
  assert(account.get_id() == note.inputs[0])
  for a in note.assets
    account.receive_asset(a)
  end 
end

The script assumes that a note comes with a single input which contains ID of the recipient's account.

Pay to account ID with recall

This script can be used when a note is intended to deposit all of its assets into a specific account within some period. If this time expires, another user (presumably the send of the note) will be able to claim all of the note's assets. The pseudocode for this script looks as follows:

begin
  if chain.get_block_height() > note.inputs[0]
    assert(account.get_id() == note.inputs[1] || account.get_id() == note.inputs[2])
  else
    assert(account.get_id() == note.inputs[1])
  end
  
  for a in note.assets
    account.receive_asset(a)
  end
end

The script assumes that a note comes with the following inputs:

  • input[0] contains block height after which the note can be reclaimed by the sender.
  • input[1] contains the recipient's account ID.
  • input[2] contains the sender's account ID.

Required procedures

These scripts require the following kernel procedures to exist:

Procedure Description Context
get account ID Returns ID of the account in the current transaction. account, note
get note assets Returns all assets in the current note. note
get note inputs Returns all inputs for the current note note
get block height Returns current block height for the transaction. note, account

They also assume that the recipient's and sender's accounts expose receive_assets procedure which can be used to deposit a single asset into the account's vault.

@Dominik1999 Dominik1999 self-assigned this Jul 28, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in Pioneer's testnet - Critical Path Sep 25, 2023
daedlock pushed a commit to keomprotocol/miden-base that referenced this issue Feb 8, 2024
…sqlite-iteration

store: add sqlite pool and initial migration for nullifier table
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

No branches or pull requests

2 participants