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:151
Properties
address
address: 0x${string};
The wallet address.
Defined
@nilfoundation/niljs/src/contracts/WalletV1/WalletV1.ts:137
client
client: PublicClient;
The client for interacting with the wallet.
Defined
@nilfoundation/niljs/src/contracts/WalletV1/WalletV1.ts:119
pubkey
pubkey: Uint8Array;
The wallet public key.
Defined
@nilfoundation/niljs/src/contracts/WalletV1/WalletV1.ts:107
salt?
optional salt: Uint8Array;
Arbitrary data for changing the wallet address.
Defined
@nilfoundation/niljs/src/contracts/WalletV1/WalletV1.ts:125
shardId
shardId: number;
The ID of the shard where the wallet is deployed.
Defined
@nilfoundation/niljs/src/contracts/WalletV1/WalletV1.ts:113
signer
signer: ISigner;
The wallet signer.
Defined
@nilfoundation/niljs/src/contracts/WalletV1/WalletV1.ts:131
abi
static abi: any = Wallet.abi;
The wallet ABI.
Static
Defined
@nilfoundation/niljs/src/contracts/WalletV1/WalletV1.ts:48
code
static code: Uint8Array;
The wallet bytecode.
Static
Defined
@nilfoundation/niljs/src/contracts/WalletV1/WalletV1.ts:41
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:432
checkDeploymentStatus()
checkDeploymentStatus(): Promise<boolean>
Checks the deployment status.
Returns
Promise
<boolean
>
The current deployment status.
Async
Defined
@nilfoundation/niljs/src/contracts/WalletV1/WalletV1.ts:255
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:488
getBalance()
getBalance(): Promise<bigint>
Returns the wallet balance.
Returns
Promise
<bigint
>
The wallet balance.
Async
Defined
@nilfoundation/niljs/src/contracts/WalletV1/WalletV1.ts:641
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:418
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:268
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:209
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:322
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:463
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:392
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:607
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:82