Este repositorio utiliza la estructura recomendada para un proyecto Soroban:
.
├── contracts
│ └── products
│ ├── src
│ │ ├── lib.rs
│ │ └── test.rs
│ └── Cargo.toml
├── Cargo.toml
├── Makefile
└── README.md
- Los contratos Soroban se ubican en
contracts, cada uno en su propio directorio. - Cada contrato tiene su propio
Cargo.tomlque depende delCargo.tomldel workspace principal.
make build # Compilar contratos
make deploy # Desplegar en testnet
make clean # Limpiar archivos compiladosImportante: Antes de ejecutar
make deploy, debes modificar elMakefiley cambiar--source-account zkCalebpor tu propia cuenta configurada en Stellar CLI.
Nota: En los comandos de prueba, el parámetro
--idpuede ser:
products- Si usaste el alias al hacer deploy (recomendado)- El Contract ID directamente (ej:
CBXYZ...) - Si ya hiciste deploy y conoces el IDTambién debes cambiar
--source-account zkCalebpor tu propia cuenta.
Linux/macOS (Bash):
stellar contract invoke \
--id products \
--source-account zkCaleb \
--network testnet \
-- \
register_product \
--name "Laptop Gaming" \
--description "Laptop 16GB RAM RTX 4060" \
--price 1500 \
--initial_stock 10Windows (PowerShell):
stellar contract invoke `
--id products `
--source-account zkCaleb `
--network testnet `
-- `
register_product `
--name "Laptop Gaming" `
--description "Laptop 16GB RAM RTX 4060" `
--price 1500 `
--initial_stock 10Linux/macOS (Bash):
# Agregar stock
stellar contract invoke \
--id products \
--source-account zkCaleb \
--network testnet \
-- \
update_stock \
--product_id 0 \
--quantity 5 \
--operation "add"
# Restar stock
stellar contract invoke \
--id products \
--source-account zkCaleb \
--network testnet \
-- \
update_stock \
--product_id 0 \
--quantity 3 \
--operation "sub"Windows (PowerShell):
# Agregar stock
stellar contract invoke `
--id products `
--source-account zkCaleb `
--network testnet `
-- `
update_stock `
--product_id 0 `
--quantity 5 `
--operation "add"
# Restar stock
stellar contract invoke `
--id products `
--source-account zkCaleb `
--network testnet `
-- `
update_stock `
--product_id 0 `
--quantity 3 `
--operation "sub"Linux/macOS (Bash):
stellar contract invoke \
--id products \
--source-account zkCaleb \
--network testnet \
-- \
update_price \
--product_id 0 \
--new_price 1200Windows (PowerShell):
stellar contract invoke `
--id products `
--source-account zkCaleb `
--network testnet `
-- `
update_price `
--product_id 0 `
--new_price 1200Linux/macOS (Bash):
stellar contract invoke \
--id products \
--source-account zkCaleb \
--network testnet \
-- \
get_product \
--product_id 0Windows (PowerShell):
stellar contract invoke `
--id products `
--source-account zkCaleb `
--network testnet `
-- `
get_product `
--product_id 0