Skip to main content

@nilfoundation/niljs

Classes

ClassDescription
BlockNotFoundErrorThe error class for 'block not found' errors. This error is thrown when the requested block is not found.
ExternalMessageEnvelopeThe envelope for an external message (a message sent by a user, a dApp, etc.)
FaucetThe Faucet is a special contract that is used to top up other contracts in the =nil; devnet.
HttpTransportHttpTransport represents the HTTP transport for connecting to the network.
ITransportThe transport interface.
IntegerOutOfRangeErrorThe error class for 'integer out of range' errors. This error is thrown when the requested integer is out of range.
InternalMessageEnvelopeThe envelope for an internal message (a message sent by a smart contract to another smart contract).
InvalidShardIdErrorThe error class for invalid shard ID. This error is thrown when the provided shard ID is invalid.
LocalECDSAKeySignerThe LocalKeySigner is a class that allows for signing data with the private key. It uses the secp256k1 curve implementation by the @noble/curves/secp256k1 library.
MetaMaskSignerThe MetaMaskSigner is a class that allows for signing data using MetaMask. This signer can only be used inside a browser.
MetaMaskTransportMetaMask transport represents the MetaMask transport for connecting to the network. MetaMask transport can be used in browser only. MetaMaskTransport
PublicClientPublicClient is a class that allows for interacting with the network via the JSON-RPC API. It provides an abstraction of the connection to =nil;. PublicClient enables using API requests that do not require signing data (or otherwise using one's private key).
WalletV1WalletV1 is a class used for performing operations on the cluster that require authentication.

Interfaces

InterfaceDescription
IMessageThe interface for the message object. This object is used to represent a message in the client code. It may differ from the actual message object used inside the network.
ISignerThe interface for the Signer class

Type Aliases

Type aliasDescription
BlockThe block type. Type T determines whether the block contains processed messages or just message hashes.
BlockTagThe block tag type.
CallParamsRepresents the message call params.
DeployParamsRepresents the params for deploying a smart contract.
ExternalMessageThe external message type.
HexThe hex type.
IClientBaseConfigThe client configuration that is shared between public and private clients.
IDeployData-
IHttpTransportConfigThe interface representing the configuration of the HTTP transport.
ILocalKeySignerConfigThe interface for the configuration object of LocalKeySigner.
ILogThe log interface.
IPrivateKeyIPrivateKey represents a private key in hexadecimal format.
IPublicClientConfigThe type representing the config for the public client.
IReceiptThe receipt interface.
ISendMessageOptionsThe options for sending a message.
ISignatureThe interface for the signature. It contains the r, s, and yParity values.
ISignedMessageThe signed message interface.
IWalletClientConfigThe type representing the config for the basic wallet.
ProcessedReceipt-
RequestParamsRepresents the params for making a request to the wallet.
SendAbiMessageParams-
SendBaseMessageParams-
SendDataMessageParams-
SendMessageParamsRepresents the params for sending a message.
SendSyncAbiMessageParams-
SendSyncBaseMessageParams-
SendSyncDataMessageParams-
SendSyncMessageParamsRepresents the params for sending a message synchronously.
WalletV1ConfigRepresents the wallet configuration.

Variables

VariableDescription
SszMessageSchemaThe SSZ schema for a message object.
SszSignedMessageSchemaSSZ schema for a signed message object. Includes auth data in addition to all other message fields.

Functions

FunctionDescription
addHexPrefixAdd the hex prefix to the hex string.
bytesToHex-
bytesToStringConverts bytes to a string.
calculateAddressCalculates an address.
concatHexConcatenates an array of hex strings. The hex strings are concatenated without the "0x" prefix. The resulting hex string will have the "0x" prefix.
convertEthToWei-
externalDeploymentMessageCreates a new external deployment message.
externalMessageEncodeEncodes the given external message.
generateRandomPrivateKeyGenerate a new private key.
getAddressFromPublicKeyReturns the address from the public key.
getPublicKeyReturns the public key from the private key using the secp256k1 curve.
getShardIdFromAddressReturns the ID of the shard containing the provided address.
hexToBigIntConverts a hex string to a bigint.
hexToBytesConverts a hex string to a byte array.
hexToNumberConverts a hex string to a number.
isAddressChecks if the value is an address. If the value is an address, returns true. Otherwise, returns false.
isHexStringChecks if the value is a hex string. If the value is a hex string, returns true. Otherwise, returns false.
isValidBlockChecks if the provided block is valid.
poseidonHashCreates the Poseidon hash of the given bytes.
refineAddressRefines the address.
removeHexPrefixRemove the hex prefix from the hex string.
toHexConverts a string, number, bigint, boolean, or ByteArrayType to a hex string.
waitTillCompletedMakes it so that the client waits until the processing of the message whose hash is passed.