mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-07-03 21:49:28 +00:00
docs: add program ID, CU costs, CLI usage, SDK docs, fix demo script timeout
This commit is contained in:
parent
0ae30c98ae
commit
3ba6139b4c
@ -144,3 +144,78 @@ RISC0_DEV_MODE=0 bash scripts/demo-full-flow.sh
|
|||||||
- [SetAuthority handler](../programs/token/src/set_authority.rs)
|
- [SetAuthority handler](../programs/token/src/set_authority.rs)
|
||||||
- [Mint handler](../programs/token/src/mint.rs)
|
- [Mint handler](../programs/token/src/mint.rs)
|
||||||
- [Solana SPL Token - Set Authority](https://solana.com/docs/tokens/basics/set-authority)
|
- [Solana SPL Token - Set Authority](https://solana.com/docs/tokens/basics/set-authority)
|
||||||
|
|
||||||
|
## Deployment
|
||||||
|
|
||||||
|
### Program ID (LEZ localnet/testnet)
|
||||||
|
efdf86b1127c57c4653903e78bd2174b539fd688054331618c48f98c8fc057bd
|
||||||
|
|
||||||
|
### Deploy
|
||||||
|
```bash
|
||||||
|
lgs deploy --program-path target/riscv-guest/token-methods/token-guest/riscv32im-risc0-zkvm-elf/release/token.bin
|
||||||
|
```
|
||||||
|
|
||||||
|
## Compute Unit (CU) Costs
|
||||||
|
|
||||||
|
Measured on LEZ localnet with RISC0_DEV_MODE=1 (execution only, no proof):
|
||||||
|
|
||||||
|
| Operation | Execution Time | Notes |
|
||||||
|
|---|---|---|
|
||||||
|
| `NewFungibleDefinitionWithAuthority` | ~11ms | Creates token with mint authority |
|
||||||
|
| `Mint` (with authority) | ~10ms | Authority-gated mint |
|
||||||
|
| `SetAuthority` (rotate) | ~8ms | Rotates to new key |
|
||||||
|
| `SetAuthority` (revoke) | ~8ms | Permanently revokes, sets None |
|
||||||
|
|
||||||
|
Note: With `RISC0_DEV_MODE=0`, full ZK proof generation takes 3-10 minutes per transaction on Apple M-series hardware. LEZ's per-transaction compute budget may change during testnet.
|
||||||
|
|
||||||
|
## CLI Usage
|
||||||
|
|
||||||
|
### Create token with mint authority
|
||||||
|
```bash
|
||||||
|
spel --idl token-idl.json --program token.bin \
|
||||||
|
-- NewFungibleDefinitionWithAuthority \
|
||||||
|
--definition-account <DEF_ID> \
|
||||||
|
--holding-account <SUPPLY_ID> \
|
||||||
|
--name "MyToken" \
|
||||||
|
--initial-supply 1000000 \
|
||||||
|
--mint-authority <AUTHORITY_KEY_HEX>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Mint tokens
|
||||||
|
```bash
|
||||||
|
spel --idl token-idl.json --program token.bin \
|
||||||
|
-- Mint \
|
||||||
|
--definition-account <DEF_ID> \
|
||||||
|
--holding-account <HOLDER_ID> \
|
||||||
|
--amount-to-mint 500000
|
||||||
|
```
|
||||||
|
|
||||||
|
### Rotate authority
|
||||||
|
```bash
|
||||||
|
spel --idl token-idl.json --program token.bin \
|
||||||
|
-- SetAuthority \
|
||||||
|
--definition-account <DEF_ID> \
|
||||||
|
--new-authority <NEW_KEY_HEX>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Revoke authority (fix supply permanently)
|
||||||
|
```bash
|
||||||
|
spel --idl token-idl.json --program token.bin \
|
||||||
|
-- SetAuthority \
|
||||||
|
--definition-account <DEF_ID> \
|
||||||
|
--new-authority none
|
||||||
|
```
|
||||||
|
|
||||||
|
## Module/SDK
|
||||||
|
|
||||||
|
`token_core` provides the reusable types and instructions for building Logos modules:
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[dependencies]
|
||||||
|
token_core = { path = "programs/token/core" }
|
||||||
|
```
|
||||||
|
|
||||||
|
Key types:
|
||||||
|
- `TokenDefinition::Fungible { mint_authority, .. }` — token definition with authority
|
||||||
|
- `Instruction::NewFungibleDefinitionWithAuthority` — create with authority
|
||||||
|
- `Instruction::SetAuthority` — rotate or revoke
|
||||||
|
|||||||
@ -1,6 +1,16 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
|
||||||
|
# Cross-platform timeout command
|
||||||
|
if command -v gtimeout &>/dev/null; then
|
||||||
|
TIMEOUT="gtimeout"
|
||||||
|
elif command -v timeout &>/dev/null; then
|
||||||
|
TIMEOUT="timeout"
|
||||||
|
else
|
||||||
|
echo "Warning: no timeout command found, running without timeout"
|
||||||
|
TIMEOUT=""
|
||||||
|
fi
|
||||||
SPEL="$HOME/rebase-lez/spel/target/release/spel"
|
SPEL="$HOME/rebase-lez/spel/target/release/spel"
|
||||||
IDL="$HOME/rebase-lez/logos-execution-zone/token-authority.idl.json"
|
IDL="$HOME/rebase-lez/logos-execution-zone/token-authority.idl.json"
|
||||||
TOKEN_BIN="$HOME/rebase-lez/logos-execution-zone/target/riscv32im-risc0-zkvm-elf/docker/token.bin"
|
TOKEN_BIN="$HOME/rebase-lez/logos-execution-zone/target/riscv32im-risc0-zkvm-elf/docker/token.bin"
|
||||||
@ -39,7 +49,7 @@ echo " Recipient account: $RECIPIENT_ID"
|
|||||||
|
|
||||||
echo "[4/7] Creating token with mint authority..."
|
echo "[4/7] Creating token with mint authority..."
|
||||||
NSSA_WALLET_HOME_DIR="$WALLET_DIR" \
|
NSSA_WALLET_HOME_DIR="$WALLET_DIR" \
|
||||||
gtimeout 30 "$SPEL" --idl "$IDL" --program "$TOKEN_BIN" \
|
${TIMEOUT:+$TIMEOUT 30} "$SPEL" --idl "$IDL" --program "$TOKEN_BIN" \
|
||||||
-- NewFungibleDefinitionWithAuthority \
|
-- NewFungibleDefinitionWithAuthority \
|
||||||
--definition-account "$DEF_ID" \
|
--definition-account "$DEF_ID" \
|
||||||
--holding-account "$SUPPLY_ID" \
|
--holding-account "$SUPPLY_ID" \
|
||||||
@ -52,7 +62,7 @@ sleep 2
|
|||||||
|
|
||||||
echo "[5/7] Minting 500,000 additional tokens..."
|
echo "[5/7] Minting 500,000 additional tokens..."
|
||||||
NSSA_WALLET_HOME_DIR="$WALLET_DIR" \
|
NSSA_WALLET_HOME_DIR="$WALLET_DIR" \
|
||||||
gtimeout 30 "$SPEL" --idl "$IDL" --program "$TOKEN_BIN" \
|
${TIMEOUT:+$TIMEOUT 30} "$SPEL" --idl "$IDL" --program "$TOKEN_BIN" \
|
||||||
-- Mint \
|
-- Mint \
|
||||||
--definition-account "$DEF_ID" \
|
--definition-account "$DEF_ID" \
|
||||||
--holding-account "$RECIPIENT_ID" \
|
--holding-account "$RECIPIENT_ID" \
|
||||||
@ -63,7 +73,7 @@ sleep 2
|
|||||||
|
|
||||||
echo "[6/7] Revoking mint authority..."
|
echo "[6/7] Revoking mint authority..."
|
||||||
NSSA_WALLET_HOME_DIR="$WALLET_DIR" \
|
NSSA_WALLET_HOME_DIR="$WALLET_DIR" \
|
||||||
gtimeout 30 "$SPEL" --idl "$IDL" --program "$TOKEN_BIN" \
|
${TIMEOUT:+$TIMEOUT 30} "$SPEL" --idl "$IDL" --program "$TOKEN_BIN" \
|
||||||
-- SetAuthority \
|
-- SetAuthority \
|
||||||
--definition-account "$DEF_ID" \
|
--definition-account "$DEF_ID" \
|
||||||
--new-authority none 2>&1 || true
|
--new-authority none 2>&1 || true
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user