SDKs:javascript:classes:Kmd.md•14.2 kB
[algosdk](../README.md) / [Exports](../modules.md) / Kmd
# Class: Kmd
## Hierarchy
- `default`
↳ **`Kmd`**
## Table of contents
### Constructors
- [constructor](Kmd.md#constructor)
### Methods
- [createWallet](Kmd.md#createwallet)
- [deleteKey](Kmd.md#deletekey)
- [deleteMultisig](Kmd.md#deletemultisig)
- [exportKey](Kmd.md#exportkey)
- [exportMasterDerivationKey](Kmd.md#exportmasterderivationkey)
- [exportMultisig](Kmd.md#exportmultisig)
- [generateKey](Kmd.md#generatekey)
- [getIntEncoding](Kmd.md#getintencoding)
- [getWallet](Kmd.md#getwallet)
- [importKey](Kmd.md#importkey)
- [importMultisig](Kmd.md#importmultisig)
- [initWalletHandle](Kmd.md#initwallethandle)
- [listKeys](Kmd.md#listkeys)
- [listMultisig](Kmd.md#listmultisig)
- [listWallets](Kmd.md#listwallets)
- [releaseWalletHandle](Kmd.md#releasewallethandle)
- [renameWallet](Kmd.md#renamewallet)
- [renewWalletHandle](Kmd.md#renewwallethandle)
- [setIntEncoding](Kmd.md#setintencoding)
- [signMultisigTransaction](Kmd.md#signmultisigtransaction)
- [signTransaction](Kmd.md#signtransaction)
- [signTransactionWithSpecificPublicKey](Kmd.md#signtransactionwithspecificpublickey)
- [versions](Kmd.md#versions)
## Constructors
### constructor
• **new Kmd**(`token`, `baseServer?`, `port?`, `headers?`)
#### Parameters
| Name | Type | Default value |
| :------ | :------ | :------ |
| `token` | `string` \| [`KMDTokenHeader`](../interfaces/KMDTokenHeader.md) \| [`CustomTokenHeader`](../interfaces/CustomTokenHeader.md) | `undefined` |
| `baseServer` | `string` | `'http://127.0.0.1'` |
| `port` | `string` \| `number` | `7833` |
| `headers` | `Object` | `{}` |
#### Overrides
ServiceClient.constructor
#### Defined in
client/kmd.ts:7
## Methods
### createWallet
▸ **createWallet**(`walletName`, `walletPassword`, `walletMDK?`, `walletDriverName?`): `Promise`\<`any`\>
createWallet creates a wallet with the specified name, password, driver,
and master derivation key. If the master derivation key is blank, one is
generated internally to kmd. CreateWallet returns a CreateWalletResponse
containing information about the new wallet.
#### Parameters
| Name | Type | Default value |
| :------ | :------ | :------ |
| `walletName` | `string` | `undefined` |
| `walletPassword` | `string` | `undefined` |
| `walletMDK` | `Uint8Array` | `undefined` |
| `walletDriverName` | `string` | `'sqlite'` |
#### Returns
`Promise`\<`any`\>
#### Defined in
client/kmd.ts:43
___
### deleteKey
▸ **deleteKey**(`walletHandle`, `walletPassword`, `addr`): `Promise`\<`any`\>
deleteKey accepts a wallet handle, wallet password, and address, and deletes
the information about this address from the wallet (including address and
secret key). If DeleteKey is called on a key generated using GenerateKey,
the same key will not be generated again. However, if a wallet is recovered
using the master derivation key, a key generated in this way can be
recovered.
#### Parameters
| Name | Type |
| :------ | :------ |
| `walletHandle` | `string` |
| `walletPassword` | `string` |
| `addr` | `string` |
#### Returns
`Promise`\<`any`\>
#### Defined in
client/kmd.ts:227
___
### deleteMultisig
▸ **deleteMultisig**(`walletHandle`, `walletPassword`, `addr`): `Promise`\<`any`\>
deleteMultisig accepts a wallet handle, wallet password, and multisig
address, and deletes the information about this multisig address from the
wallet (including address and secret key).
#### Parameters
| Name | Type |
| :------ | :------ |
| `walletHandle` | `string` |
| `walletPassword` | `string` |
| `addr` | `string` |
#### Returns
`Promise`\<`any`\>
#### Defined in
client/kmd.ts:411
___
### exportKey
▸ **exportKey**(`walletHandle`, `walletPassword`, `addr`): `Promise`\<\{ `private_key`: `Buffer` }\>
exportKey accepts a wallet handle, wallet password, and address, and returns
an ExportKeyResponse containing the ed25519 private key corresponding to the
address stored in the wallet.
#### Parameters
| Name | Type |
| :------ | :------ |
| `walletHandle` | `string` |
| `walletPassword` | `string` |
| `addr` | `string` |
#### Returns
`Promise`\<\{ `private_key`: `Buffer` }\>
#### Defined in
client/kmd.ts:191
___
### exportMasterDerivationKey
▸ **exportMasterDerivationKey**(`walletHandle`, `walletPassword`): `Promise`\<\{ `master_derivation_key`: `Buffer` }\>
exportMasterDerivationKey accepts a wallet handle and a wallet password, and
returns an ExportMasterDerivationKeyResponse containing the master
derivation key. This key can be used as an argument to CreateWallet in
order to recover the keys generated by this wallet. The master derivation
key can be encoded as a sequence of words using the mnemonic library, and
#### Parameters
| Name | Type |
| :------ | :------ |
| `walletHandle` | `string` |
| `walletPassword` | `string` |
#### Returns
`Promise`\<\{ `master_derivation_key`: `Buffer` }\>
#### Defined in
client/kmd.ts:150
___
### exportMultisig
▸ **exportMultisig**(`walletHandle`, `addr`): `Promise`\<`any`\>
exportMultisig accepts a wallet handle, wallet password, and multisig
address, and returns an ExportMultisigResponse containing the stored
multisig preimage. The preimage contains all of the information necessary
to derive the multisig address, including version, threshold, and a list of
public keys.
#### Parameters
| Name | Type |
| :------ | :------ |
| `walletHandle` | `string` |
| `addr` | `string` |
#### Returns
`Promise`\<`any`\>
#### Defined in
client/kmd.ts:363
___
### generateKey
▸ **generateKey**(`walletHandle`): `Promise`\<`any`\>
generateKey accepts a wallet handle, and then generates the next key in the
wallet using its internal master derivation key. Two wallets with the same
master derivation key will generate the same sequence of keys.
#### Parameters
| Name | Type |
| :------ | :------ |
| `walletHandle` | `string` |
#### Returns
`Promise`\<`any`\>
#### Defined in
client/kmd.ts:207
___
### getIntEncoding
▸ **getIntEncoding**(): [`IntDecoding`](../enums/IntDecoding.md)
Get the default int decoding method for all JSON requests this client creates.
#### Returns
[`IntDecoding`](../enums/IntDecoding.md)
#### Inherited from
ServiceClient.getIntEncoding
#### Defined in
client/v2/serviceClient.ts:86
___
### getWallet
▸ **getWallet**(`walletHandle`): `Promise`\<`any`\>
getWallet accepts a wallet handle and returns high level information about
this wallet in a GetWalletResponse.
#### Parameters
| Name | Type |
| :------ | :------ |
| `walletHandle` | `string` |
#### Returns
`Promise`\<`any`\>
#### Defined in
client/kmd.ts:133
___
### importKey
▸ **importKey**(`walletHandle`, `secretKey`): `Promise`\<`any`\>
importKey accepts a wallet handle and an ed25519 private key, and imports
the key into the wallet. It returns an ImportKeyResponse containing the
address corresponding to this private key.
#### Parameters
| Name | Type |
| :------ | :------ |
| `walletHandle` | `string` |
| `secretKey` | `Uint8Array` |
#### Returns
`Promise`\<`any`\>
#### Defined in
client/kmd.ts:174
___
### importMultisig
▸ **importMultisig**(`walletHandle`, `version`, `threshold`, `pks`): `Promise`\<`any`\>
importMultisig accepts a wallet handle and the information required to
generate a multisig address. It derives this address, and stores all of the
information within the wallet. It returns a ImportMultisigResponse with the
derived address.
#### Parameters
| Name | Type |
| :------ | :------ |
| `walletHandle` | `string` |
| `version` | `number` |
| `threshold` | `number` |
| `pks` | `string`[] |
#### Returns
`Promise`\<`any`\>
#### Defined in
client/kmd.ts:337
___
### initWalletHandle
▸ **initWalletHandle**(`walletID`, `walletPassword`): `Promise`\<`any`\>
initWalletHandle accepts a wallet ID and a wallet password, and returns an
initWalletHandleResponse containing a wallet handle token. This wallet
handle token can be used for subsequent operations on this wallet, like key
generation, transaction signing, etc.. WalletHandleTokens expire after a
configurable number of seconds, and must be renewed periodically with
RenewWalletHandle. It is good practice to call ReleaseWalletHandle when
you're done interacting with this wallet.
#### Parameters
| Name | Type |
| :------ | :------ |
| `walletID` | `string` |
| `walletPassword` | `string` |
#### Returns
`Promise`\<`any`\>
#### Defined in
client/kmd.ts:70
___
### listKeys
▸ **listKeys**(`walletHandle`): `Promise`\<`any`\>
ListKeys accepts a wallet handle and returns a ListKeysResponse containing
all of the addresses for which this wallet contains secret keys.
#### Parameters
| Name | Type |
| :------ | :------ |
| `walletHandle` | `string` |
#### Returns
`Promise`\<`any`\>
#### Defined in
client/kmd.ts:242
___
### listMultisig
▸ **listMultisig**(`walletHandle`): `Promise`\<`any`\>
listMultisig accepts a wallet handle and returns a ListMultisigResponse
containing the multisig addresses whose preimages are stored in this wallet.
A preimage is the information needed to reconstruct this multisig address,
including multisig version information, threshold information, and a list
of public keys.
#### Parameters
| Name | Type |
| :------ | :------ |
| `walletHandle` | `string` |
#### Returns
`Promise`\<`any`\>
#### Defined in
client/kmd.ts:319
___
### listWallets
▸ **listWallets**(): `Promise`\<`any`\>
listWallets returns a ListWalletsResponse containing the list of wallets known to kmd. Using a wallet ID
returned from this endpoint, you can initialize a wallet handle with client.InitWalletHandle
#### Returns
`Promise`\<`any`\>
#### Defined in
client/kmd.ts:28
___
### releaseWalletHandle
▸ **releaseWalletHandle**(`walletHandle`): `Promise`\<`any`\>
releaseWalletHandle invalidates the passed wallet handle token, making
it unusuable for subsequent wallet operations.
#### Parameters
| Name | Type |
| :------ | :------ |
| `walletHandle` | `string` |
#### Returns
`Promise`\<`any`\>
#### Defined in
client/kmd.ts:84
___
### renameWallet
▸ **renameWallet**(`walletID`, `walletPassword`, `newWalletName`): `Promise`\<`any`\>
renameWallet accepts a wallet ID, wallet password, and a new wallet name,
and renames the underlying wallet.
#### Parameters
| Name | Type |
| :------ | :------ |
| `walletID` | `string` |
| `walletPassword` | `string` |
| `newWalletName` | `string` |
#### Returns
`Promise`\<`any`\>
#### Defined in
client/kmd.ts:114
___
### renewWalletHandle
▸ **renewWalletHandle**(`walletHandle`): `Promise`\<`any`\>
renewWalletHandle accepts a wallet handle and attempts to renew it, moving
the expiration time to some number of seconds in the future. It returns a
RenewWalletHandleResponse containing the walletHandle and the number of
seconds until expiration
#### Parameters
| Name | Type |
| :------ | :------ |
| `walletHandle` | `string` |
#### Returns
`Promise`\<`any`\>
#### Defined in
client/kmd.ts:99
___
### setIntEncoding
▸ **setIntEncoding**(`method`): `void`
Set the default int decoding method for all JSON requests this client creates.
#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
| `method` | [`IntDecoding`](../enums/IntDecoding.md) | {"default" \| "safe" \| "mixed" \| "bigint"} method The method to use when parsing the response for request. Must be one of "default", "safe", "mixed", or "bigint". See JSONRequest.setIntDecoding for more details about what each method does. |
#### Returns
`void`
#### Inherited from
ServiceClient.setIntEncoding
#### Defined in
client/v2/serviceClient.ts:79
___
### signMultisigTransaction
▸ **signMultisigTransaction**(`walletHandle`, `pw`, `transaction`, `pk`, `partial`): `Promise`\<`any`\>
signMultisigTransaction accepts a wallet handle, wallet password,
transaction, public key (*not* an address), and an optional partial
MultisigSig. It looks up the secret key corresponding to the public key, and
returns a SignMultisigTransactionResponse containing a MultisigSig with a
signature by the secret key included.
#### Parameters
| Name | Type |
| :------ | :------ |
| `walletHandle` | `string` |
| `pw` | `string` |
| `transaction` | [`TransactionLike`](../modules.md#transactionlike) |
| `pk` | `string` \| `Uint8Array` |
| `partial` | `string` |
#### Returns
`Promise`\<`any`\>
#### Defined in
client/kmd.ts:384
___
### signTransaction
▸ **signTransaction**(`walletHandle`, `walletPassword`, `transaction`): `Promise`\<`any`\>
signTransaction accepts a wallet handle, wallet password, and a transaction,
and returns and SignTransactionResponse containing an encoded, signed
transaction. The transaction is signed using the key corresponding to the
Sender field.
#### Parameters
| Name | Type |
| :------ | :------ |
| `walletHandle` | `string` |
| `walletPassword` | `string` |
| `transaction` | [`TransactionLike`](../modules.md#transactionlike) |
#### Returns
`Promise`\<`any`\>
#### Defined in
client/kmd.ts:259
___
### signTransactionWithSpecificPublicKey
▸ **signTransactionWithSpecificPublicKey**(`walletHandle`, `walletPassword`, `transaction`, `publicKey`): `Promise`\<`any`\>
signTransactionWithSpecificPublicKey accepts a wallet handle, wallet password, a transaction, and a public key,
and returns and SignTransactionResponse containing an encoded, signed
transaction. The transaction is signed using the key corresponding to the
publicKey arg.
#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
| `walletHandle` | `string` | |
| `walletPassword` | `string` | |
| `transaction` | [`TransactionLike`](../modules.md#transactionlike) | |
| `publicKey` | `string` \| `Uint8Array` | sign the txn with the key corresponding to publicKey (used for working with a rekeyed addr) |
#### Returns
`Promise`\<`any`\>
#### Defined in
client/kmd.ts:289
___
### versions
▸ **versions**(): `Promise`\<`any`\>
version returns a VersionResponse containing a list of kmd API versions supported by this running kmd instance.
#### Returns
`Promise`\<`any`\>
#### Defined in
client/kmd.ts:19