How to make an agoric address using cosmjs? #5830
-
@dtribble asked for a quick example of making an address using the cosmjs library. |
Beta Was this translation helpful? Give feedback.
Answered by
0xpatrickdev
Feb 21, 2023
Replies: 1 comment 4 replies
-
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
for a complete example including cc @dtribble |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @dckc, I was looking into this more after reading #6994.
In order to match an address generated by the Keplr client, I found that I needed to use
coinType: 564
.Looking here, Agoric's slip44 parameter is 564. In the keplr registry, I see
bip44.coinType
= 564, but further down I also see analternativeBIP44s
field which contains 118. This leads me to believe both 118 and 564 are valid, but I wanted to see if you could provide more color here.@tgrecojs also shared this doc which was a helpful resource for me: https://github.com/confio/cosmos-hd-key-derivation-spec/blob/main/README.md
Here is an implementation with
coinType: 564
-DirectSecp256k1Wallet
does not allow us to specify coinT…