Skip to main content

Wallet

@node-fi/sdk-core / Exports / Wallet

Class: Wallet<T>

Type parameters

NameType
Textends Signer = Signer

Hierarchy

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new Wallet<T>(_signer, apiKey, homeChain?, address?, wid?)

Type parameters

NameType
Textends Signer<T> = Signer

Parameters

NameTypeDefault valueDescription
_signerundefined | TundefinedSigner to use for signing transactions
apiKeystringundefinedstring, API key required to authenticate payloads
homeChainChainIdChainId.Celohomechain for the wallet. Default is Celo for now
address?stringundefinedaddress of the wallet. EOA or smart wallet
wid?numberundefinedwid of the wallet. Used for node wallet backend

Defined in

packages/sdk-core/src/wallet/NodeWallet.ts:157

Properties

_address

Private _address: undefined | string

Defined in

packages/sdk-core/src/wallet/NodeWallet.ts:142


_apiKey

Private _apiKey: string

Defined in

packages/sdk-core/src/wallet/NodeWallet.ts:145


_chain

Private _chain: ChainId

Defined in

packages/sdk-core/src/wallet/NodeWallet.ts:143


_isNodeWallet

Private _isNodeWallet: boolean = true

Defined in

packages/sdk-core/src/wallet/NodeWallet.ts:141


_provider

Private _provider: Provider

Defined in

packages/sdk-core/src/wallet/NodeWallet.ts:147


_signer

Private _signer: undefined | T

Defined in

packages/sdk-core/src/wallet/NodeWallet.ts:158


_wid

Private Optional _wid: number

Defined in

packages/sdk-core/src/wallet/NodeWallet.ts:146


network

Optional network: Network

Defined in

packages/sdk-core/src/wallet/NodeWallet.ts:144

Accessors

address

get address(): undefined | string

Returns

undefined | string

Address of the wallet

Defined in

packages/sdk-core/src/wallet/NodeWallet.ts:192


apiKey

get apiKey(): string

Returns

string

Defined in

packages/sdk-core/src/wallet/NodeWallet.ts:227


chain

get chain(): ChainId

Returns

ChainId

Home chain for the wallet

Defined in

packages/sdk-core/src/wallet/NodeWallet.ts:209


feeCurrency

get feeCurrency(): undefined | string

Returns

undefined | string

Fee currency for the wallet

Defined in

packages/sdk-core/src/wallet/NodeWallet.ts:199


provider

get provider(): Provider

Returns

Provider

Provider for the wallet

Defined in

packages/sdk-core/src/wallet/NodeWallet.ts:223


signer

get signer(): undefined | T

Returns

undefined | T

Signer for the wallet

Defined in

packages/sdk-core/src/wallet/NodeWallet.ts:185


wid

get wid(): undefined | number

Returns

undefined | number

Wid of the wallet

Defined in

packages/sdk-core/src/wallet/NodeWallet.ts:216

Methods

connect

connect(signerOrProviderOrAddress): Promise<Wallet<T>>

Connect a signer to the wallet

Parameters

NameTypeDescription
signerOrProviderOrAddressTSigner, provider or address to connect

Returns

Promise<Wallet<T>>

Wallet instance

Defined in

packages/sdk-core/src/wallet/NodeWallet.ts:282

connect(signerOrProviderOrAddress): Promise<Wallet<JsonRpcSigner>>

Parameters

NameType
signerOrProviderOrAddressJsonRpcProvider

Returns

Promise<Wallet<JsonRpcSigner>>

Defined in

packages/sdk-core/src/wallet/NodeWallet.ts:283


fetchBackendPortfolioValue

fetchBackendPortfolioValue(interval, timeframe, currency?): Promise<undefined | { time: number ; total: number }[]>

Fetches the wallet's historical portfolio for a given time period of resolution. Portfolio value is given in the declared currency code.

Parameters

NameTypeDefault valueDescription
intervalIntervalundefinedtime interval between ticks
timeframeTimeFrameundefinedtimeframe on which to view historical portfolio value
currencystring"usd"base currency code for the query

Returns

Promise<undefined | { time: number ; total: number }[]>

an array of portfolio values at specific times, where the time in between ticks corresponds to interval

Defined in

packages/sdk-core/src/wallet/NodeWallet.ts:554


fetchFromWalletService

fetchFromWalletService(): Promise<boolean>

Fetches details on the wallet from the Node Finace wallet service. Includes metadata set by developer.

Returns

Promise<boolean>

Wallet object

Defined in

packages/sdk-core/src/wallet/NodeWallet.ts:368


fetchPaymentRequests

fetchPaymentRequests<MetaDataShape>(getToken, opts?): Promise<{ pageInfo: PageInfo ; requests: PaymentRequest<MetaDataShape>[] }>

Fetches payment requests for a wallet. Can fetch pending, completed, or all. Default pagination is page 0, with 10 per page.

Type parameters

NameType
MetaDataShapeextends Record<string, unknown>

Parameters

NameTypeDescription
getToken(address: string) => TokenCallback to fetch a token given its address
opts?ObjectOptions for the query, including request type, page, and count per page
opts.count?number-
opts.page?number-
opts.type?"all" | "pending" | "completed"-

Returns

Promise<{ pageInfo: PageInfo ; requests: PaymentRequest<MetaDataShape>[] }>

List of payment requests for the wallet

Defined in

packages/sdk-core/src/wallet/NodeWallet.ts:485


fetchPortfolioRaw

fetchPortfolioRaw(opts): Promise<{ time: number ; total: number }[]>

Parameters

NameType
optsObject
opts.chain?number
opts.currency?string
opts.endTime?number
opts.resolution?Interval
opts.startTime?number

Returns

Promise<{ time: number ; total: number }[]>

Defined in

packages/sdk-core/src/wallet/NodeWallet.ts:569


fulfillPaymentRequest

fulfillPaymentRequest<T>(request, amount): Promise<{ receipt: TransactionResponse }>

Handles repaying a portion, or all of, a payment request.

Type parameters

NameType
Textends Record<string, unknown> = Record<string, unknown>

Parameters

NameTypeDescription
requestPaymentRequest<T>PaymentRequest object to fulfill
amountTokenAmountThe total token amount to pay towards this payment request. Does not have to equal the remaining amount.

Returns

Promise<{ receipt: TransactionResponse }>

Request after crediting payment, and receipt of payment

Defined in

packages/sdk-core/src/wallet/NodeWallet.ts:437


getHistoricalTransactions

getHistoricalTransactions(getTokens, opts?): Promise<TokenTransactionBase[]>

Parameters

NameTypeDescription
getTokens(address: string) => TokenCallback to fetch a token given its address
opts?ObjectPage options and currency code options
opts.localCurrencyCode?string-
opts.page?number-
opts.perPage?number-

Returns

Promise<TokenTransactionBase[]>

List of transactions for the wallet, additionally with local value transacted

Defined in

packages/sdk-core/src/wallet/NodeWallet.ts:308


register

register(metadata?, optInTracking?): Promise<Wallet<T>>

Parameters

NameTypeDefault valueDescription
metadataObject{}additional metadata to be stored with the wallet
optInTrackingbooleanfalseopt in to tracking

Returns

Promise<Wallet<T>>

Wallet object

Defined in

packages/sdk-core/src/wallet/NodeWallet.ts:333


requestPayment

requestPayment<T>(from, amount, deadline?, metadata?): Promise<PaymentRequest<T>>

Authenticates and creates a new payment request

Type parameters

NameType
Textends Record<string, unknown>

Parameters

NameTypeDescription
fromstringAddress to request payment from
amountTokenAmountToken and amount to request
deadline?DateOptional date that payment must be fulfilled
metadata?TAdditional metadata to store regarding the request

Returns

Promise<PaymentRequest<T>>

PaymentRequest object corresponding to the newly-created request

Defined in

packages/sdk-core/src/wallet/NodeWallet.ts:464


setFeeCurrency

setFeeCurrency(tokenAddress): string

Set the default gas currency. Only applicable on Celo and Alfajores, otherwise will fail

Parameters

NameTypeDescription
tokenAddressstringToken address to use to pay gas fees.

Returns

string

Defined in

packages/sdk-core/src/wallet/NodeWallet.ts:420


signAndSendContractTransactions

signAndSendContractTransactions(descriptions, opts?): Promise<TransactionReceipt>

Deprecated

use wallet.signer to sign transactions instead

Parameters

NameTypeDescription
descriptionsContractTransaction[]descriptions of transactions to sign and process
opts?TransactionOptions-

Returns

Promise<TransactionReceipt>

transaction receipt from executed txn

Defined in

packages/sdk-core/src/wallet/NodeWallet.ts:599


signAndSendNodeTransactions

signAndSendNodeTransactions(transactions, opts?): Promise<TransactionReceipt>

Deprecated

use wallet.signer to sign transactions instead

Parameters

NameTypeDescription
transactionsNodeWalletTransaction[]transaction descriptions in a more readable format
opts?TransactionOptions-

Returns

Promise<TransactionReceipt>

transaction receipt

Defined in

packages/sdk-core/src/wallet/NodeWallet.ts:625


signAndSendTransaction

signAndSendTransaction(transaction, opts?): Promise<TransactionReceipt>

Deprecated

use wallet.signer to sign transactions instead

Parameters

NameType
transactionTransactionRequest | TransactionRequest[]
opts?TransactionOptions

Returns

Promise<TransactionReceipt>

Defined in

packages/sdk-core/src/wallet/NodeWallet.ts:642


signAndSendTransactions

signAndSendTransactions(transactions, opts?): Promise<TransactionReceipt[]>

Deprecated

use wallet.signer to sign transactions instead

Parameters

NameType
transactionsTransactionRequest[]
opts?TransactionOptions

Returns

Promise<TransactionReceipt[]>

transaction receipt

Defined in

packages/sdk-core/src/wallet/NodeWallet.ts:674


signMessage

signMessage(data): Promise<Signature>

Parameters

NameTypeDescription
datastringMessage to sign

Returns

Promise<Signature>

A Sign object, which contains all fields needed to recompute original signer, as well as the signed message

Defined in

packages/sdk-core/src/wallet/NodeWallet.ts:539


signMessageRaw

signMessageRaw(data): Promise<string>

Parameters

NameTypeDescription
datastringMessage to sign

Returns

Promise<string>

A Sign object, which contains all fields needed to recompute original signer, as well as the signed message

Defined in

packages/sdk-core/src/wallet/NodeWallet.ts:529


transferToken

transferToken(token, amount, recipient, overrides?): Promise<TransactionResponse>

Sends a token from this wallet to any other address.

Parameters

NameTypeDescription
tokenstring | TokenToken to send
amountBigintIshAmount to send
recipientstringRecipient of transfer
overridesOmit<TransactionRequest, "data" | "to" | "value">-

Returns

Promise<TransactionResponse>

Receipt of transaction of sending the token

Defined in

packages/sdk-core/src/wallet/NodeWallet.ts:396


isWallet

Static isWallet(o): o is Wallet<Signer>

Parameters

NameTypeDescription
ounknownunknown object

Returns

o is Wallet<Signer>

true if the wallet is a node wallet

Defined in

packages/sdk-core/src/wallet/NodeWallet.ts:236


loadAsync

Static loadAsync<T>(getSigner, apiKey): Promise<undefined | Wallet<Signer>>

Type parameters

NameType
Textends Signer<T>

Parameters

NameTypeDescription
getSigner() => T | Promise<T>Callback to fetch the signer
apiKeystringAPI key required to authenticate payloads

Returns

Promise<undefined | Wallet<Signer>>

Wallet instance

Defined in

packages/sdk-core/src/wallet/NodeWallet.ts:245


loadFromConfig

Static loadFromConfig(config, chain, apiKey): Promise<undefined | Wallet<Signer>>

Load a wallet from a config object

Parameters

NameTypeDescription
configWalletConfigWalletConfig object
chainChainIdChainId of the wallet
apiKeystringAPI key required to authenticate payloads

Returns

Promise<undefined | Wallet<Signer>>

Wallet instance

Defined in

packages/sdk-core/src/wallet/NodeWallet.ts:264