Connect Nightly
access to the Nightly wallet object. :::
To view the implementation of the connect method, and the ones described in the later chapters,
visit our source code.
Source code: https://github.com/nightly-labs/movement-web3-template/blob/main/app/components/StickyHeader.tsx
In order to start using Nightly extension, an app needs to establish a connection. Once the connection request is initiated on the application side, it will prompt the user to provide permission to connect to the app with Nightly.
Connect
To wrap the Nightly object acquired from the previous step with an adapter to allow seamless
interaction, you should use the StandardWalletAdapter class from the
@aptos-labs/wallet-standard.
We recommend calling connect() function, in order to establish connection with Nightly.
into the connect method. While you can update the network later using a dedicated method
Changing adapter network , we recommend setting it upfront
for a more robust and consistent experience. :::
import { AptosWallet, Network, NetworkInfo } from '@aptos-labs/wallet-standard';
// THIS IS THE CRUCIAL DIFFERENCE
const networkInfo: NetworkInfo = {
chainId: 126, // Movement Mainnet chain ID
name: Network.CUSTOM,
};
// Assuming nightly is the detected Nightly Wallet object
const adapter = nightly.standardWallet as AptosWallet;
await adapter.features['aptos:connect'].connect(SILENT_CONNECT, networkInfo);
In the table below you can see the network info params for all supported movement networks.
| Network | chainId | name |
|---|---|---|
| Movement Mainnet | 126 | Network.CUSTOM |
| Bardock Testnet | 250 | Network.CUSTOM |
Disconnect
We recommend calling disconnect() function, in order to break connection with Nightly.
await adapter.features['aptos:disconnect'].disconnect()