Security News
JavaScript Leaders Demand Oracle Release the JavaScript Trademark
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
@cosmjs/amino
Advanced tools
Helpers for Amino based signing which are shared between @cosmjs/launchpad and @cosmjs/stargate.
@cosmjs/amino is a JavaScript library for working with the Amino encoding format used in the Cosmos ecosystem. It provides tools for encoding and decoding data structures, signing transactions, and interacting with Cosmos-based blockchains.
Encoding and Decoding
This feature allows you to encode and decode data structures using the Amino encoding format. The code sample demonstrates encoding a Cosmos SDK message and then decoding it back to its original form.
const { encode, decode } = require('@cosmjs/amino');
const data = { type: 'cosmos-sdk/MsgSend', value: { from_address: 'cosmos1...', to_address: 'cosmos1...', amount: [{ denom: 'uatom', amount: '1000' }] } };
const encoded = encode(data);
const decoded = decode(encoded);
console.log(encoded);
console.log(decoded);
Signing Transactions
This feature allows you to create and serialize a sign document for transactions. The code sample demonstrates creating a sign document for a transaction and serializing it.
const { makeSignDoc, serializeSignDoc, StdSignDoc } = require('@cosmjs/amino');
const signDoc = makeSignDoc([{ type: 'cosmos-sdk/MsgSend', value: { from_address: 'cosmos1...', to_address: 'cosmos1...', amount: [{ denom: 'uatom', amount: '1000' }] } }], { amount: [{ denom: 'uatom', amount: '500' }], gas: '200000' }, 'cosmoshub-4', 'memo', 1, 1);
const serializedSignDoc = serializeSignDoc(signDoc);
console.log(serializedSignDoc);
Interacting with Cosmos-based Blockchains
This feature allows you to interact with Cosmos-based blockchains, including signing and broadcasting transactions. The code sample demonstrates creating a wallet, signing a transaction, and broadcasting it to the Cosmos network.
const { makeSignDoc, serializeSignDoc, StdSignDoc } = require('@cosmjs/amino');
const { DirectSecp256k1HdWallet } = require('@cosmjs/proto-signing');
const { assertIsBroadcastTxSuccess, SigningStargateClient } = require('@cosmjs/stargate');
async function main() {
const wallet = await DirectSecp256k1HdWallet.fromMnemonic('your mnemonic here');
const [firstAccount] = await wallet.getAccounts();
const client = await SigningStargateClient.connectWithSigner('https://rpc.cosmos.network', wallet);
const msgSend = {
type: 'cosmos-sdk/MsgSend',
value: {
from_address: firstAccount.address,
to_address: 'cosmos1...',
amount: [{ denom: 'uatom', amount: '1000' }]
}
};
const fee = {
amount: [{ denom: 'uatom', amount: '500' }],
gas: '200000'
};
const result = await client.signAndBroadcast(firstAccount.address, [msgSend], fee, 'memo');
assertIsBroadcastTxSuccess(result);
console.log(result);
}
main().catch(console.error);
@cosmjs/proto-signing is a library for signing Cosmos SDK transactions using Protobuf encoding. It provides similar functionality to @cosmjs/amino but uses Protobuf instead of Amino for encoding.
cosmjs-types is a library that provides TypeScript definitions for Cosmos SDK Protobuf messages. It is useful for developers who want to work with Protobuf-encoded messages in a type-safe manner.
cosmos-client is a JavaScript client library for interacting with Cosmos SDK-based blockchains. It provides higher-level abstractions for common tasks such as querying the blockchain and broadcasting transactions.
FAQs
Helpers for Amino based signing.
The npm package @cosmjs/amino receives a total of 148,414 weekly downloads. As such, @cosmjs/amino popularity was classified as popular.
We found that @cosmjs/amino demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.