_112 MsgGrantAuthorization,
_112} from '@terra-money/feather.js';
_112 spendLimit: Coins.Input,
_112 new MsgGrantAuthorization(
_112 granter.key.accAddress('terra'),
_112 new SendAuthorization(spendLimit),
_112 return granter.createAndSignTx({ msgs, chainID: 'pisco-1' });
_112function sendAuthorized(
_112 amount: Coins.Input,
_112 new MsgExecAuthorized(grantee.key.accAddress, [
_112 granter.key.accAddress('terra'), // From test1
_112 return grantee.createAndSignTx({ msgs, chainID: 'pisco-1' });
_112async function main() {
_112 const client = new LCDClient(...);
_112 // Granter (terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v)
_112 const granter = client.wallet(
_112 'notice oak worry limit wrap speak medal online prefer cluster roof addict wrist behave treat actual wasp year salad speed social layer crew genius',
_112 // Grantee (terra17lmam6zguazs5q5u6z5mmx76uj63gldnse2pdp)
_112 const grantee = client.wallet(
_112 'quality vacuum heart guard buzz spike sight swarm shove special gym robust assume sudden deposit grid alcohol choice devote leader tilt noodle tide penalty',
_112 // MsgGrantAuthorization
_112 grantee.key.accAddress('terra'),
_112 // Set enough spend limit since it will be decreased upon every MsgSend transactions
_112 '1000000000000uluna',
_112 // expire after 100 years
_112 new Int(86400 * 365 * 100 * 1000000000),
_112 .then((tx) => client.tx.broadcast(tx, 'pisco-1'))
_112 console.error(err.response.data);
_112 console.error(err.message);
_112 // MsgExecAuthorized of MsgSend
_112 await sendAuthorized(
_112 'terra1757tkx08n0cqrw7p86ny9lnxsqeth0wgp0em95',
_112 '2000000000000uluna',
_112 .then((tx) => client.tx.broadcast(tx, 'pisco-1'))
_112 // unauthorized: authorization not found: failed to execute message; message index: 0: failed to simulate tx
_112 // happens when the granted amount of tokens is exceeded.
_112 // insufficient funds: insufficient account funds; ...
_112 // happens when granter does not have enough tokens
_112 console.error(err.response.data);
_112 console.error(err.message);
_112main().catch(console.error);