On-Ramp SDK
Getting started
- Please make sure that there is either a deployed OnRamp API service or you are running it localy.
- Install the SDK package from the archive.
- Import the on ramp sdk with this line of code:
import {OnRampSdk} from '@codefi/on-ramp-sdk'
On-Ramp SDK
To facilitate back-end interaction, a SDK can be used.
You can use it like this:
const sdk: IOnRampSdk = await OnRampSdk.getSDK(
Environment.Staging,
Context.Mobile,
{
verbose: true,
maxInstanceCount: 1,
},
)
Local Development with MetaMask Portfolio
To connect a local instance of the SDK to a local MetaMask Portfolio client, follow these steps:
1. Update SDK Configuration
- Open the
tsconfig.json
file in the SDK project. - Modify the
module
and moduleResolution
properties as follows:
{
"compilerOptions": {
"module": "esnext",
"moduleResolution": "node"
}
}
2. Link SDK to Portfolio
-
In the SDK project directory, run the following command to create a symbolic link:
yarn link
-
In the Portfolio project directory, link the SDK by running:
yarn link @consensys/on-ramp-sdk
-
Remove the cache to ensure the changes take effect:
rm -rf node_modules/.cache
3. Install Dependencies
- In the Portfolio project directory, install the necessary packages:
yarn install
4. Update Vite Configuration
- Open the
vite.config.js
file in the Portfolio project. - Add the following configuration to exclude the SDK from dependency optimization:
export default {
optimizeDeps: {
exclude: ['@consensys/on-ramp-sdk'],
},
}
5. Rebuild After SDK Changes
Whenever you make changes to the SDK, remember to rebuild the project to reflect those changes in the Portfolio client:
yarn build