Observed since 20 Oct, 22:43 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Signer for Pocket Network V0 accounts
This package houses both the abstract Key Manager interface we expose to people so that they build their own KeyManager, and an actual KeyManager ready to use for handling account-related operations.
Install through your package manager of choice:
pnpm install @pokt-foundation/pocketjs-signer
import { AbstractSigner, KeyManager } from '@pokt-foundation/pocketjs-signer'
// For the AbstractSigner, just implement it!
class MySigner extends AbstractSigner {
// Now override the required methods...
}
// For the KeyManager, there's a few ways you can initialize it:
// 1. Create a random (new) account with the KeyManager
const randomAccount = await KeyManager.createRandom()
// 2. Use a private key you own
const account = await KeyManager.fromPrivateKey(process.env.PRIVATE_KEY);
// 3. Use a Portable-Private-Key file, stringified.
// A PPK is generated by exporting an account through the `exportPPK` method.
const ppkAccount = await KeyManager.fromPPK({ password: process.env.PASS, ppk: process.env.PPK })
// Now, you can use it!
// Get your address
const address = account.getAddress()
// Get your public key
const publicKey = account.getPublicKey()
// Sign a message
const signedCoffee = account.sign("0xcafe")
Instanciating through the constructor is only possible if all params are known beforehand. If not, use one of the initialization methods provided.
Creates a new, random pocket account. Can be called from the base class as it's static.
Returns a Promise<KeyManager>: The new key manager instance with the account attached.
Instanciates a new KeyManager from a valid ED25519 private key.
Returns a Promise<KeyManager>: The new key manager instance with the account attached.
| Param | Type | Description |
|---|---|---|
| privateKey | string | The private key to use for instanciating the account. |
Instanciates a new KeyManager from a valid Portable-Private-Key file.
Returns a Promise<KeyManager>: The new key manager instance with the account attached.
| Param | Type | Description |
|---|---|---|
| password | string | The password of the account to instanciate from the PPK. |
| ppk | string | PPK, stringified. (PPKs are valid JSON files) |
Exports a provided private key as a Portable-Private-Key, unlockable with the provided password.
Returns a Promise<string>: A PPK, in stringified manner.
| Param | Type | Description |
|---|---|---|
| password | string | The password to use in the PPK. |
| privateKey | string | The private key to create the PPK from. |
| hint | string | The password hint. |
Exports the current account's private key as a Portable-Private-Key, unlockable with the provided password.
Returns a Promise<string>: A PPK, in stringified manner.
| Param | Type | Description |
|---|---|---|
| password | string | The password to use in the PPK. |
| hint | string | The password hint. |
Signs a valid hex-string payload with the imported private key.
Returns a Promise<string>: The signed payload as a string.
| Param | Type | Description |
|---|---|---|
| payload | string | The hex payload to sign. |
Gets the account address.
Returns string: The attached account's address.
Gets teh account public key.
Returns string: The attached account's public key.
Gets the account private key.
Returns string: The attached account's private key.
Gets the attached account.
Returns Account: The attached account in its entirety in an object.
Download counts and popularity will appear here as the collector receives them.
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 22:43 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:5dbbfb7d6b3ce8c4dc3be84513c2769e83982b0872ec67c98721dbd42807c5e1