tx op agregar
Como se vio antes, puedes usar tuberías para pasar un sobre de transacción entre comandos. Antes solo hemos estado viendo transacciones con una operación, sin embargo, como se mencionó, puede haber hasta 100 operaciones en una sola transacción.
Para agregar una operación a una transacción, puedes usar el comando tx op agregar
. Este comando toma el sobre de la transacción del comando anterior y le agrega una operación.
Considera un ejemplo más complicado. Considera emitir un activo, aquí USDC
, con el requisito de que solo el emisor puede transferir fondos al distribuidor.
stellar keys generate --fund issuer
stellar keys generate --fund distributor
ISSUER_PK=$(stellar keys address issuer)
ASSET="USDC:$ISSUER_PK"
# Issue the asset by setting its options, establishing a trustline, and
# transferring the smallest amount possible to the distributor. Then
# deauthorize the distributor so that people can only send Claimable Balances,
# rather than transferring assets directly.
# first the issuer sets the options for being able to clawback and revoke the asset
stellar tx new set-options --fee 1000 --source issuer --set-clawback-enabled --set-revocable --build-only \
# next the distributor establishes a trustline with the asset. Note that here the distributor the source account for the operation, not the issuer
| stellar tx op add change-trust --op-source distributor --line $ASSET \
# then the issuer sends the smallest amount possible to the distributor
| stellar tx op add payment --destination distributor --asset $ASSET --amount 1 \
# finally the issuer deauthorizes the distributor from being able to send the asset
| stellar tx op add set-trustline-flags --asset $ASSET --trustor distributor --clear-authorize \
# Then both accounts need to sign the transaction
| stellar tx sign --sign-with-key issuer \
| stellar tx sign --sign-with-key distributor \
| stellar tx send
# Next is an example of sandwiching an operation. That is giving permission in one operation, preforming the operation, and then removing the permission in a third operation.
# Here is an example of minting new assets to the distributor with a sandwich transaction
# First authorize the distributor to receive the asset
stellar tx new set-trustline-flags --fee 1000 --build-only --source issuer --asset $ASSET --trustor $distributor_PK --set-authorize \
# Then mint the asset to the distributor
| stellar tx op add payment --destination distributor --asset $ASSET --amount 1_000_000_000_000 \
# Finally remove the authorization
| stellar tx op add set-trustline-flags --asset $ASSET --trustor distributor --clear-authorize \
| stellar tx sign --sign-with-key issuer \
| stellar tx send
Guías en esta categoría:
📄️ Ciclo de Vida del Contrato
Gestionar el ciclo de vida de un contrato inteligente Stellar utilizando la CLI
📄️ Desplegar un contrato a partir de bytecode Wasm instalado
Desplegar una instancia de un contrato compilado que ya está instalado en la red
📄️ Desplegar el Contrato de Activo Stellar para un activo Stellar
Desplegar un SAC para un activo Stellar para que pueda interactuar con contratos inteligentes
📄️ Extender el TTL de una instancia de contrato desplegada
Usar el CLI para extender el tiempo de vida (TTL) de una instancia de contrato
📄️ Extender el TTL de la entrada de almacenamiento de un contrato desplegado
Usar la CLI para extender el tiempo de vida (TTL) de la entrada de almacenamiento persistente de un contrato
📄️ Extender el TTL del código Wasm de un contrato desplegado
Usar Stellar CLI para extender el TTL del bytecode Wasm del contrato, con o sin binario local
📄️ Instalar y desplegar un contrato inteligente
Combina los comandos de instalar y desplegar en la Stellar CLI para realizar ambas tareas
📄️ Instalar el código de bytes de Wasm
Usa el CLI de Stellar para instalar un contrato inteligente compilado en el ledger
📄️ Pagos y Activos
Envía XLM, stellar classic o un activo soroban usando el CLI de Stellar
📄️ Restaurar un contrato archivado usando el CLI de Stellar
Restaurar una instancia de contrato archivada usando el CLI de Stellar
📄️ Restaurar datos de contrato archivados utilizando el CLI de Stellar
Restaurar entradas de almacenamiento de contrato archivadas utilizando el CLI de Stellar
📄️ Comandos tx
Crear transacciones Stellar utilizando el CLI de Stellar
📄️ tx op agregar
Crear transacciones Stellar usando el CLI de Stellar
📄️ firma tx y envía tx
Crear transacciones stellar utilizando el CLI de Stellar