Skip to content

Custom providers

If you're using this SDK in a browser environment where your users will be signing transactions, the SDK will try to use the window.ethereum provider by default.

However, you might want to use a custom wallet kit like web3modal or rainbowkit along with wagmi.

Using a custom provider

For example, you might be using web3modal + wagmi to manage wallet connections.

You can use the withAccount method to override the provider.

example.ts
import { mintclub, wei } from 'mint.club-v2-sdk'
import { useAccount } from 'wagmi'
 
function App() {
	const account = useAccount() 
 
	mintclub.network('ethereum')
	.withAccount(account) 
	.token('SYMBOL')
	.buy({
		amount: wei(1, 18),
	})
}

Other use cases

There are cases where you might want to use a custom provider or use the SDK in a non-browser environment to sign the transaction.

Using a custom provider

Using a private key

Using an account

Using the PublicClient

Using the WalletClient

Overriding PublicClient config

Overriding WalletClient config