If you want to connect Keplr to a secret network within the Cosmos ecosystem, you can easily connect using SecretJs. SecretJs is a JavaScript SDK for writing applications that interact with the Secret Network blockchain. If you are curious about the Secret Network in the Cosmos ecosystem, you can check it out here.
코스모스 생태계 안에 있는 시크릿 네트워크와 케플러를 연결하고 싶다면 SecretJs를 써서 쉽게 연결할 수 있습니다. SecretJs는 시크릿 네트워크 블록체인과 상호 작용하는 응용 프로그램을 작성하기 위한 자바스크립트 SDK입니. 만약 코스모스 생태계에 있는 Secret Network 에 대해서 궁금하다면 이곳에서 확인해볼 수 있습니다.
- Written in TypeScript and provided with type definitions.
- Provides simple abstractions over core data structures.
- Supports every possible message and transaction type.
- Exposes every possible query type.
- Handles input/output encryption/decryption for Secret Contracts.
- Works in Node.js, modern web browsers and React Native.
SecretJS link: https://www.npmjs.com/package/secretjs (opens new window)The basics of using SecretJS is similar to CosmJS. Refer to the Use with CosmJs section for more information.
One difference between CosmJS and SecretJS is that we recommend using Keplr's EnigmaUtils
. By using Keplr's EnigmaUtils
, you can use Keplr to encrypt/decrypt, and the decrypted transaction messages are shown to the user in a human-readable format.
// Enabling before using the Keplr is recommended.
// This method will ask the user whether or not to allow access if they haven't visited this website.
// Also, it will request user to unlock the wallet if the wallet is locked.
await window.keplr.enable(chainId);
const offlineSigner = window.getOfflineSigner(chainId);
**const enigmaUtils = window.getEnigmaUtils(chainId);**
// You can get the address/public keys by `getAccounts` method.
// It can return the array of address/public key.
// But, currently, Keplr extension manages only one address/public key pair.
// XXX: This line is needed to set the sender address for SigningCosmosClient.
const accounts = await offlineSigner.getAccounts();
// Initialize the gaia api with the offline signer that is injected by Keplr extension.
const cosmJS = new SigningCosmWasmClient(
"https://lcd-secret.keplr.app/rest",
accounts[0].address,
offlineSigner,
**enigmaUtils**
);
async suggestToken(chainId: string, contractAddress: string): Promise<void>
The webpage can request the user permission to add a SNIP-20 token to Keplr's token list. Will throw an error if the user rejects the request. If a SNIP-20 with the same contract address already exists, nothing will happen.
getSecret20ViewingKey(
chainId: string,
contractAddress: string
): Promise<string>;
Returns the viewing key of a SNIP-20 token registered in Keplr. If the SNIP-20 of the contract address doesn't exist, it will throw an error.
You can use Keplr native API’s to set interaction options even when using SecretJS. Please refer to this section.\