Class: WalletV1
WalletV1 is a class used for performing operations on the cluster that require authentication.
WalletV1
Implements
WalletInterface
Constructors
new WalletV1()
new WalletV1(param0): WalletV1
Creates an instance of WalletV1.
Parameters
Parameter | Type | Description |
---|---|---|
| The object representing the initial wallet config. See WalletV1Config. |
Returns
Defined
@nilfoundation/niljs/src/contracts/WalletV1/WalletV1.ts:150
Properties
address
address: 0x${string};
The wallet address.
Defined
@nilfoundation/niljs/src/contracts/WalletV1/WalletV1.ts:136
client
client: PublicClient;
The client for interacting with the wallet.
Defined
@nilfoundation/niljs/src/contracts/WalletV1/WalletV1.ts:118
pubkey
pubkey: Uint8Array;
The wallet public key.
Defined
@nilfoundation/niljs/src/contracts/WalletV1/WalletV1.ts:106
salt?
optional salt: Uint8Array;
Arbitrary data for changing the wallet address.
Defined
@nilfoundation/niljs/src/contracts/WalletV1/WalletV1.ts:124
shardId
shardId: number;
The ID of the shard where the wallet is deployed.
Defined
@nilfoundation/niljs/src/contracts/WalletV1/WalletV1.ts:112
signer
signer: ISigner;
The wallet signer.
Defined
@nilfoundation/niljs/src/contracts/WalletV1/WalletV1.ts:130
abi
static abi: Abi;
The wallet ABI.
Static
Defined
@nilfoundation/niljs/src/contracts/WalletV1/WalletV1.ts:47
code
static code: Uint8Array;
The wallet bytecode.
Static
Defined
@nilfoundation/niljs/src/contracts/WalletV1/WalletV1.ts:40
Methods
burnCurrency()
burnCurrency(amount): Promise<any>
Burns the currency that the wallet owns.
Parameters
Parameter | Type |
---|---|
|
|
Returns
Promise
<any
>
The message hash.
Async
Example
const hashMessage = await wallet.burnCurrency(burnCurrency);
await waitTillCompleted(client, hashMessage);
Defined
@nilfoundation/niljs/src/contracts/WalletV1/WalletV1.ts:431
checkDeploymentStatus()
checkDeploymentStatus(): Promise<boolean>
Checks the deployment status.
Returns
Promise
<boolean
>
The current deployment status.
Async
Defined
@nilfoundation/niljs/src/contracts/WalletV1/WalletV1.ts:254
deployContract()
deployContract(param0): Promise<object>
Deploys a new smart contract via the wallet.
Parameters
Parameter | Type | Description |
---|---|---|
| The object representing the contract deployment params. |
Returns
Promise
<object
>
The object containing the deployment message hash and the contract address.
address
address: any;
hash
hash: any;
Async
Defined
@nilfoundation/niljs/src/contracts/WalletV1/WalletV1.ts:487
getBalance()
getBalance(): Promise<bigint>
Returns the wallet balance.
Returns
Promise
<bigint
>
The wallet balance.
Async
Defined
@nilfoundation/niljs/src/contracts/WalletV1/WalletV1.ts:640
mintCurrency()
mintCurrency(amount): Promise<any>
Mints the currency that the wallet owns and withdraws it to the wallet. setCurrencyName has to be called first before minting a currency.
Parameters
Parameter | Type |
---|---|
|
|
Returns
Promise
<any
>
The message hash.
Async
Example
const hashMessage = await wallet.mintCurrency(mintCount);
await waitTillCompleted(client, hashMessage);
Defined
@nilfoundation/niljs/src/contracts/WalletV1/WalletV1.ts:417
requestToWallet()
requestToWallet(requestParams, send?): Promise<object>
Performs a request to the wallet.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
|
| The object representing the request parameters. | |
|
|
| The flag that determines whether the request is sent when the function is called. |
Returns
Promise
<object
>
The message bytecode and hash.
chainId
chainId: number;
hash
hash: Uint8Array;
raw
raw: Uint8Array;
seqno
seqno: number;
Async
Defined
@nilfoundation/niljs/src/contracts/WalletV1/WalletV1.ts:267
selfDeploy()
selfDeploy(waitTillConfirmation?): Promise<Uint8Array>
Deploys the wallet.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
|
|
| The flag that determines whether the function waits for deployment confirmation before exiting. |
Returns
Promise
<Uint8Array
>
The hash of the deployment transaction.
Async
Example
import {
Faucet,
HttpTransport,
LocalECDSAKeySigner,
PublicClient,
WalletV1,
generateRandomPrivateKey,
} from '@nilfoundation/niljs';
const client = new PublicClient({
transport: new HttpTransport({
endpoint: RPC_ENDPOINT,
}),
shardId: 1,
});
const signer = new LocalECDSAKeySigner({
privateKey: generateRandomPrivateKey(),
});
const faucet = new Faucet(client);
await faucet.withdrawTo(walletAddress, 100000n);
const pubkey = signer.getPublicKey();
const wallet = new WalletV1({
pubkey: pubkey,
salt: 100n,
shardId: 1,
client,
signer,
address: WalletV1.calculateWalletAddress({
pubKey: pubkey,
shardId: 1,
salt: 100n,
}),
});
await wallet.selfDeploy(true);
Defined
@nilfoundation/niljs/src/contracts/WalletV1/WalletV1.ts:208
sendMessage()
sendMessage(param0): Promise<any>
Send a message via the wallet.
Parameters
Parameter | Type | Description |
---|---|---|
|
| The object representing the message params. |
Returns
Promise
<any
>
The message hash.
Async
Example
const anotherAddress = WalletV1.calculateWalletAddress({
pubKey: pubkey,
shardId: 1,
salt: 200n,
});
await wallet.sendMessage({
to: anotherAddress,
value: 10n,
gas: 100000n,
});
Implementation of
WalletInterface.sendMessage
Defined
@nilfoundation/niljs/src/contracts/WalletV1/WalletV1.ts:321
sendRawInternalMessage()
sendRawInternalMessage(rawMessage): Promise<any>
Send a raw signed message via the wallet.
Parameters
Parameter | Type | Description |
---|---|---|
|
| The message bytecode. |
Returns
Promise
<any
>
The message hash.
Async
Defined
@nilfoundation/niljs/src/contracts/WalletV1/WalletV1.ts:462
setCurrencyName()
setCurrencyName(name): Promise<any>
Sets the name of the custom currency that the wallet can own and mint.
Parameters
Parameter | Type |
---|---|
|
|
Returns
Promise
<any
>
The message hash.
Async
Example
const hashMessage = await wallet.setCurrencyName("MY_TOKEN");
await waitTillCompleted(client, hashMessage);
Defined
@nilfoundation/niljs/src/contracts/WalletV1/WalletV1.ts:391
syncSendMessage()
syncSendMessage(param0): Promise<any>
Creates a new message and performs a synchronous call to the specified address.
Parameters
Parameter | Type | Description |
---|---|---|
| The object representing the message params. |
Returns
Promise
<any
>
The message hash.
Async
Example
const anotherAddress = WalletV1.calculateWalletAddress({
pubKey: pubkey,
shardId: 1,
salt: 200n,
});
await wallet.sendMessage({
to: anotherAddress,
value: 10n,
gas: 100000n,
});
Defined
@nilfoundation/niljs/src/contracts/WalletV1/WalletV1.ts:606
calculateWalletAddress()
static calculateWalletAddress(param0): 0x${string}
Calculates the address of the new wallet.
Parameters
Parameter | Type | Description |
---|---|---|
|
| The object representing the config for address calculation. |
|
| The wallet public key. |
|
| Arbitrary data change the address. |
|
| The ID of the shard where the wallet should be deployed. |
Returns
0x${string}
The address of the new wallet.
Static
Example
import {
LocalECDSAKeySigner,
WalletV1,
generateRandomPrivateKey,
} from '@nilfoundation/niljs';
const signer = new LocalECDSAKeySigner({
privateKey: generateRandomPrivateKey(),
});
const pubkey = signer.getPublicKey();
const anotherAddress = WalletV1.calculateWalletAddress({
pubKey: pubkey,
shardId: 1,
salt: 200n,
});
Defined
@nilfoundation/niljs/src/contracts/WalletV1/WalletV1.ts:81