Skip to content

How to make an agoric address using cosmjs? #5830

Answered by dckc
dckc asked this question in Q&A
Discussion options

You must be logged in to vote

The basic outline is:

import { Random } from '@cosmjs/crypto';
import { DirectSecp256k1Wallet } from '@cosmjs/proto-signing';

export const bech32Config = {
  bech32PrefixAccAddr: 'agoric',
 // ...
};

const makeAddr = async () => {
    const seed = Random.getBytes(32);
    const wallet = await DirectSecp256k1Wallet.fromKey(seed, bech32Config.bech32PrefixAccAddr);
    const accounts = await wallet.getAccounts()
    console.log({ accounts });
};

makeAddr().catch(err => console.error(err));

and out comes

{
  accounts: [
    {
      address: 'agoric1pnhkj4ay6qt60pk6t8efmlf5775s8z9a9s0v97',
...

for a complete example including package.json and all that, see https://gist.github.com/dckc/7aa4…

Replies: 1 comment 4 replies

Comment options

dckc
Jul 26, 2022
Collaborator Author

You must be logged in to vote
4 replies
@0xpatrickdev
Comment options

@0xpatrickdev
Comment options

@dckc
Comment options

dckc Feb 22, 2023
Collaborator Author

@0xpatrickdev
Comment options

Answer selected by dckc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants