[@node-fi/sdk-core](../README.md) / [Exports](../modules.md) / SmartWallet

# Class: SmartWallet

Implementation of wallet as a Smart Contract wallet

## Hierarchy

- [`Wallet`](Wallet.md)

  ↳ **`SmartWallet`**

## Table of contents

### Constructors

- [constructor](SmartWallet.md#constructor)

### Properties

- [address](SmartWallet.md#address)
- [connection](SmartWallet.md#connection)
- [contract](SmartWallet.md#contract)
- [eoa](SmartWallet.md#eoa)
- [feeCurrency](SmartWallet.md#feecurrency)
- [getMnemonic](SmartWallet.md#getmnemonic)
- [homeChain](SmartWallet.md#homechain)
- [rpc](SmartWallet.md#rpc)
- [web3](SmartWallet.md#web3)
- [wid](SmartWallet.md#wid)

### Methods

- [\_loadWallet](SmartWallet.md#_loadwallet)
- [createWallet](SmartWallet.md#createwallet)
- [fetchBackendPortfolioValue](SmartWallet.md#fetchbackendportfoliovalue)
- [fetchFromWalletService](SmartWallet.md#fetchfromwalletservice)
- [fetchPaymentRequests](SmartWallet.md#fetchpaymentrequests)
- [fetchPortfolioRaw](SmartWallet.md#fetchportfolioraw)
- [fulfillPaymentRequest](SmartWallet.md#fulfillpaymentrequest)
- [getHistoricalTransactions](SmartWallet.md#gethistoricaltransactions)
- [loadWalletContract](SmartWallet.md#loadwalletcontract)
- [register](SmartWallet.md#register)
- [requestPayment](SmartWallet.md#requestpayment)
- [setFeeCurrency](SmartWallet.md#setfeecurrency)
- [signAndSendContractTransactions](SmartWallet.md#signandsendcontracttransactions)
- [signAndSendNodeTransactions](SmartWallet.md#signandsendnodetransactions)
- [signAndSendTransaction](SmartWallet.md#signandsendtransaction)
- [signMessage](SmartWallet.md#signmessage)
- [signTypedData](SmartWallet.md#signtypeddata)
- [syncBackendPortfolioValue](SmartWallet.md#syncbackendportfoliovalue)
- [transferToken](SmartWallet.md#transfertoken)

## Constructors

### constructor

• **new SmartWallet**(`apiKey?`, `homeChain?`, `address?`, `options?`)

#### Parameters

| Name | Type | Default value | Description |
| :------ | :------ | :------ | :------ |
| `apiKey?` | `string` | `undefined` | string, API key required to authenticate payloads |
| `homeChain` | [`ChainId`](../enums/ChainId.md) | `ChainId.Celo` | homechain for the wallet. Default is Celo for now |
| `address?` | `string` | `undefined` | address of the wallet.  EOA or smart wallet |
| `options?` | `WalletOptions` | `undefined` | - |

#### Inherited from

[Wallet](Wallet.md).[constructor](Wallet.md#constructor)

#### Defined in

[wallet/Wallet.ts:88](https://github.com/Node-Fi/SDK-Core/blob/1f4f819/src/wallet/Wallet.ts#L88)

## Properties

### address

• **address**: `undefined` \| `string`

#### Inherited from

[Wallet](Wallet.md).[address](Wallet.md#address)

#### Defined in

[wallet/Wallet.ts:72](https://github.com/Node-Fi/SDK-Core/blob/1f4f819/src/wallet/Wallet.ts#L72)

___

### connection

• `Protected` `Optional` **connection**: `Connection`

#### Inherited from

[Wallet](Wallet.md).[connection](Wallet.md#connection)

#### Defined in

[wallet/Wallet.ts:79](https://github.com/Node-Fi/SDK-Core/blob/1f4f819/src/wallet/Wallet.ts#L79)

___

### contract

• `Private` **contract**: `undefined` \| `NodeWallet`

#### Defined in

[wallet/SmartWallet.ts:20](https://github.com/Node-Fi/SDK-Core/blob/1f4f819/src/wallet/SmartWallet.ts#L20)

___

### eoa

• **eoa**: `undefined` \| [`EOA`](EOA.md)

#### Defined in

[wallet/SmartWallet.ts:19](https://github.com/Node-Fi/SDK-Core/blob/1f4f819/src/wallet/SmartWallet.ts#L19)

___

### feeCurrency

• `Optional` **feeCurrency**: `string`

#### Inherited from

[Wallet](Wallet.md).[feeCurrency](Wallet.md#feecurrency)

#### Defined in

[wallet/Wallet.ts:78](https://github.com/Node-Fi/SDK-Core/blob/1f4f819/src/wallet/Wallet.ts#L78)

___

### getMnemonic

• **getMnemonic**: `undefined` \| () => `Promise`<`string`\>

#### Inherited from

[Wallet](Wallet.md).[getMnemonic](Wallet.md#getmnemonic)

#### Defined in

[wallet/Wallet.ts:76](https://github.com/Node-Fi/SDK-Core/blob/1f4f819/src/wallet/Wallet.ts#L76)

___

### homeChain

• **homeChain**: [`ChainId`](../enums/ChainId.md)

#### Inherited from

[Wallet](Wallet.md).[homeChain](Wallet.md#homechain)

#### Defined in

[wallet/Wallet.ts:73](https://github.com/Node-Fi/SDK-Core/blob/1f4f819/src/wallet/Wallet.ts#L73)

___

### rpc

• `Optional` **rpc**: [`CustomRPC`](../interfaces/CustomRPC.md)

#### Inherited from

[Wallet](Wallet.md).[rpc](Wallet.md#rpc)

#### Defined in

[wallet/Wallet.ts:74](https://github.com/Node-Fi/SDK-Core/blob/1f4f819/src/wallet/Wallet.ts#L74)

___

### web3

• **web3**: `default`

#### Inherited from

[Wallet](Wallet.md).[web3](Wallet.md#web3)

#### Defined in

[wallet/Wallet.ts:75](https://github.com/Node-Fi/SDK-Core/blob/1f4f819/src/wallet/Wallet.ts#L75)

___

### wid

• `Optional` **wid**: `number`

#### Inherited from

[Wallet](Wallet.md).[wid](Wallet.md#wid)

#### Defined in

[wallet/Wallet.ts:80](https://github.com/Node-Fi/SDK-Core/blob/1f4f819/src/wallet/Wallet.ts#L80)

## Methods

### \_loadWallet

▸ **_loadWallet**(`config`): `Promise`<[`SmartWallet`](SmartWallet.md)\>

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `config` | `WalletConfig` | Configuration object specifying details about the wallet |

#### Returns

`Promise`<[`SmartWallet`](SmartWallet.md)\>

Boolean flag indicating successful wallet load

#### Overrides

[Wallet](Wallet.md).[_loadWallet](Wallet.md#_loadwallet)

#### Defined in

[wallet/SmartWallet.ts:22](https://github.com/Node-Fi/SDK-Core/blob/1f4f819/src/wallet/SmartWallet.ts#L22)

___

### createWallet

▸ `Private` **createWallet**(): `Promise`<`string`\>

#### Returns

`Promise`<`string`\>

#### Defined in

[wallet/SmartWallet.ts:47](https://github.com/Node-Fi/SDK-Core/blob/1f4f819/src/wallet/SmartWallet.ts#L47)

___

### 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

| Name | Type | Default value | Description |
| :------ | :------ | :------ | :------ |
| `interval` | [`Interval`](../enums/Interval.md) | `undefined` | time interval between ticks |
| `timeframe` | [`TimeFrame`](../modules.md#timeframe) | `undefined` | timeframe on which to view historical portfolio value |
| `currency` | `string` | `"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

#### Inherited from

[Wallet](Wallet.md).[fetchBackendPortfolioValue](Wallet.md#fetchbackendportfoliovalue)

#### Defined in

[wallet/Wallet.ts:378](https://github.com/Node-Fi/SDK-Core/blob/1f4f819/src/wallet/Wallet.ts#L378)

___

### fetchFromWalletService

▸ **fetchFromWalletService**(): `Promise`<[`SmartWallet`](SmartWallet.md)\>

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

#### Returns

`Promise`<[`SmartWallet`](SmartWallet.md)\>

Wallet object

#### Inherited from

[Wallet](Wallet.md).[fetchFromWalletService](Wallet.md#fetchfromwalletservice)

#### Defined in

[wallet/Wallet.ts:170](https://github.com/Node-Fi/SDK-Core/blob/1f4f819/src/wallet/Wallet.ts#L170)

___

### fetchPaymentRequests

▸ **fetchPaymentRequests**<`MetaDataShape`\>(`getToken`, `opts?`): `Promise`<{ `pageInfo`: [`PageInfo`](../interfaces/PageInfo.md) ; `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

| Name | Type |
| :------ | :------ |
| `MetaDataShape` | extends `Record`<`string`, `any`\> |

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `getToken` | (`address`: `string`) => [`Token`](Token.md) | Callback to fetch a token given its address |
| `opts?` | `Object` | Options for the query, including request type, page, and count per page |
| `opts.count?` | `number` | - |
| `opts.page?` | `number` | - |
| `opts.type?` | ``"pending"`` \| ``"completed"`` \| ``"all"`` | - |

#### Returns

`Promise`<{ `pageInfo`: [`PageInfo`](../interfaces/PageInfo.md) ; `requests`: `PaymentRequest`<`MetaDataShape`\>[]  }\>

List of payment requests for the wallet

#### Inherited from

[Wallet](Wallet.md).[fetchPaymentRequests](Wallet.md#fetchpaymentrequests)

#### Defined in

[wallet/Wallet.ts:318](https://github.com/Node-Fi/SDK-Core/blob/1f4f819/src/wallet/Wallet.ts#L318)

___

### fetchPortfolioRaw

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

#### Parameters

| Name | Type |
| :------ | :------ |
| `opts` | `Object` |
| `opts.chain?` | `number` |
| `opts.currency?` | `string` |
| `opts.endTime?` | `number` |
| `opts.resolution?` | [`Interval`](../enums/Interval.md) |
| `opts.startTime?` | `number` |

#### Returns

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

#### Inherited from

[Wallet](Wallet.md).[fetchPortfolioRaw](Wallet.md#fetchportfolioraw)

#### Defined in

[wallet/Wallet.ts:393](https://github.com/Node-Fi/SDK-Core/blob/1f4f819/src/wallet/Wallet.ts#L393)

___

### fulfillPaymentRequest

▸ **fulfillPaymentRequest**<`T`\>(`request`, `amount`): `default`<{ `receipt`: { `amountCredited`: [`TokenAmount`](TokenAmount.md) ; `hash`: `string` ; `isFullyRepaid`: `boolean` ; `rid`: `number` ; `time`: `number`  } ; `request`: `PaymentRequest`<`T`\>  }\>

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

#### Type parameters

| Name | Type |
| :------ | :------ |
| `T` | extends `Record`<`string`, `unknown`\> = `Record`<`string`, `any`\> |

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `request` | `PaymentRequest`<`T`\> | PaymentRequest object to fulfill |
| `amount` | [`TokenAmount`](TokenAmount.md) | The total token amount to pay towards this payment request.  Does not have to equal the remaining amount. |

#### Returns

`default`<{ `receipt`: { `amountCredited`: [`TokenAmount`](TokenAmount.md) ; `hash`: `string` ; `isFullyRepaid`: `boolean` ; `rid`: `number` ; `time`: `number`  } ; `request`: `PaymentRequest`<`T`\>  }\>

Request after crediting payment, and receipt of payment

#### Inherited from

[Wallet](Wallet.md).[fulfillPaymentRequest](Wallet.md#fulfillpaymentrequest)

#### Defined in

[wallet/Wallet.ts:245](https://github.com/Node-Fi/SDK-Core/blob/1f4f819/src/wallet/Wallet.ts#L245)

___

### getHistoricalTransactions

▸ **getHistoricalTransactions**(`getTokens`, `opts?`): `Promise`<[`TokenTransactionBase`](../interfaces/TokenTransactionBase.md)[]\>

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `getTokens` | (`address`: `string`) => [`Token`](Token.md) | Callback to fetch a token given its address |
| `opts?` | `Object` | Page options and currency code options |
| `opts.localCurrencyCode?` | `string` | - |
| `opts.page?` | `number` | - |
| `opts.perPage?` | `number` | - |

#### Returns

`Promise`<[`TokenTransactionBase`](../interfaces/TokenTransactionBase.md)[]\>

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

#### Inherited from

[Wallet](Wallet.md).[getHistoricalTransactions](Wallet.md#gethistoricaltransactions)

#### Defined in

[wallet/Wallet.ts:122](https://github.com/Node-Fi/SDK-Core/blob/1f4f819/src/wallet/Wallet.ts#L122)

___

### loadWalletContract

▸ `Private` **loadWalletContract**(): `Promise`<`string`\>

#### Returns

`Promise`<`string`\>

#### Defined in

[wallet/SmartWallet.ts:34](https://github.com/Node-Fi/SDK-Core/blob/1f4f819/src/wallet/SmartWallet.ts#L34)

___

### register

▸ **register**(): `Promise`<`undefined` \| [`SmartWallet`](SmartWallet.md)\>

Registers the wallet with the Node Finance Wallet Service.

Will return error if wallet is already registered

#### Returns

`Promise`<`undefined` \| [`SmartWallet`](SmartWallet.md)\>

#### Inherited from

[Wallet](Wallet.md).[register](Wallet.md#register)

#### Defined in

[wallet/Wallet.ts:141](https://github.com/Node-Fi/SDK-Core/blob/1f4f819/src/wallet/Wallet.ts#L141)

___

### requestPayment

▸ **requestPayment**<`T`\>(`from`, `amount`, `deadline?`, `metadata?`): `Promise`<`PaymentRequest`<`T`\>\>

Authenticates and creates a new payment request

#### Type parameters

| Name | Type |
| :------ | :------ |
| `T` | extends `Record`<`string`, `any`\> |

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `from` | `string` | Address to request payment from |
| `amount` | [`TokenAmount`](TokenAmount.md) | Token and amount to request |
| `deadline?` | `Date` | Optional date that payment must be fulfilled |
| `metadata?` | `T` | Additional metadata to store regarding the request |

#### Returns

`Promise`<`PaymentRequest`<`T`\>\>

PaymentRequest object corresponding to the newly-created request

#### Inherited from

[Wallet](Wallet.md).[requestPayment](Wallet.md#requestpayment)

#### Defined in

[wallet/Wallet.ts:297](https://github.com/Node-Fi/SDK-Core/blob/1f4f819/src/wallet/Wallet.ts#L297)

___

### setFeeCurrency

▸ **setFeeCurrency**(`tokenAddress`): `void`

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

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `tokenAddress` | `string` | Token address to use to pay gas fees. |

#### Returns

`void`

#### Inherited from

[Wallet](Wallet.md).[setFeeCurrency](Wallet.md#setfeecurrency)

#### Defined in

[wallet/Wallet.ts:216](https://github.com/Node-Fi/SDK-Core/blob/1f4f819/src/wallet/Wallet.ts#L216)

___

### signAndSendContractTransactions

▸ **signAndSendContractTransactions**(`descriptions`, `opts?`): `Promise`<`TransactionReceipt`\>

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `descriptions` | `ContractTransaction`[] | descriptions of transactions to sign and process |
| `opts?` | [`TransactionOptions`](../interfaces/TransactionOptions.md) | - |

#### Returns

`Promise`<`TransactionReceipt`\>

transaction receipt from executed txn

#### Inherited from

[Wallet](Wallet.md).[signAndSendContractTransactions](Wallet.md#signandsendcontracttransactions)

#### Defined in

[wallet/Wallet.ts:421](https://github.com/Node-Fi/SDK-Core/blob/1f4f819/src/wallet/Wallet.ts#L421)

___

### signAndSendNodeTransactions

▸ **signAndSendNodeTransactions**(`transactions`, `opts?`): `Promise`<`TransactionReceipt`\>

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `transactions` | `NodeWalletTransaction`[] | transaction descriptions in a more readable format |
| `opts?` | [`TransactionOptions`](../interfaces/TransactionOptions.md) | - |

#### Returns

`Promise`<`TransactionReceipt`\>

transaction receipt

#### Inherited from

[Wallet](Wallet.md).[signAndSendNodeTransactions](Wallet.md#signandsendnodetransactions)

#### Defined in

[wallet/Wallet.ts:446](https://github.com/Node-Fi/SDK-Core/blob/1f4f819/src/wallet/Wallet.ts#L446)

___

### signAndSendTransaction

▸ **signAndSendTransaction**(`transactions`, `opts?`): `Promise`<`TransactionReceipt`\>

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `transactions` | `TransactionConfig`[] | web3js transaction objects to sign and process |
| `opts?` | [`TransactionOptions`](../interfaces/TransactionOptions.md) | - |

#### Returns

`Promise`<`TransactionReceipt`\>

transaction receipt

#### Overrides

[Wallet](Wallet.md).[signAndSendTransaction](Wallet.md#signandsendtransaction)

#### Defined in

[wallet/SmartWallet.ts:64](https://github.com/Node-Fi/SDK-Core/blob/1f4f819/src/wallet/SmartWallet.ts#L64)

___

### signMessage

▸ **signMessage**(`data`): `Sign`

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `data` | `string` | Message to sign |

#### Returns

`Sign`

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

#### Overrides

[Wallet](Wallet.md).[signMessage](Wallet.md#signmessage)

#### Defined in

[wallet/SmartWallet.ts:88](https://github.com/Node-Fi/SDK-Core/blob/1f4f819/src/wallet/SmartWallet.ts#L88)

___

### signTypedData

▸ **signTypedData**(`data`): `Sign`

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `data` | `Mixed`[] | Data and type definitions to sign |

#### Returns

`Sign`

Signature payload

#### Inherited from

[Wallet](Wallet.md).[signTypedData](Wallet.md#signtypeddata)

#### Defined in

[wallet/Wallet.ts:229](https://github.com/Node-Fi/SDK-Core/blob/1f4f819/src/wallet/Wallet.ts#L229)

___

### syncBackendPortfolioValue

▸ **syncBackendPortfolioValue**(): `Promise`<`boolean`\>

#### Returns

`Promise`<`boolean`\>

true if success, false if unsuccessful

#### Inherited from

[Wallet](Wallet.md).[syncBackendPortfolioValue](Wallet.md#syncbackendportfoliovalue)

#### Defined in

[wallet/Wallet.ts:363](https://github.com/Node-Fi/SDK-Core/blob/1f4f819/src/wallet/Wallet.ts#L363)

___

### transferToken

▸ **transferToken**(`token`, `amount`, `recipient`): `Promise`<`TransactionReceipt`\>

Sends a token from this wallet to any other address.

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `token` | `string` \| [`Token`](Token.md) | Token to send |
| `amount` | `BigNumber` | Amount to send |
| `recipient` | `string` | Recipient of transfer |

#### Returns

`Promise`<`TransactionReceipt`\>

Receipt of transaction of sending the token

#### Inherited from

[Wallet](Wallet.md).[transferToken](Wallet.md#transfertoken)

#### Defined in

[wallet/Wallet.ts:191](https://github.com/Node-Fi/SDK-Core/blob/1f4f819/src/wallet/Wallet.ts#L191)
