Check documentation: https://docs.mycelium.sh
A TypeScript-based SDK that implements wallet management via ERC-4337 smart account and access to crypto yield opportunities though integrated protocols under the hood. The SDK allows integrators to easily onboard users, manage wallets, and interact with DeFi protocols
The Mycelium SDK simplifies on-chain interactions by creating and managing a smart wallet with an embedded wallet as a signer for blockchain related operations. Smart wallet as well as embedded wallet signer are non-custodial and only a user has a direct access to it. The embedded wallet management is delegated to the Privy platform
SDK has the following core features:
- Create a smart wallet with embedded OR external wallet as a signer
- Smart wallet core features: send/receive funds, sign transaction/message
- Fetch crypto yield opportunities
- Deposit or withdraw funds to/from a particular yield opportunity
- Fetch information about yield and balance for a specific opportunity where funds are
- Fund wallet via Coinbase: Generates a top-up link for the user to deposit funds
An integrator can define basic settings for yield opportunities that will be recommended to a end user through SDK. More about this you can find on the Protocol security config section
Mycelium SDK is an open-source and publicly available to anyone for the usage. Despite this, there are 2 versions of Mycelium SDK that can be used by an integrator:
- Self-hosted Clone the underlying repository, provide all necessary settings for providers that are used under the hood (Privy, Coinbase, etc). Right after this, you can use an integrated to a self hosted SDK version protocol - Spark. For more protocols, you need to switch to the cloud version
- Cloud
This version covers everything for an integrator. You just use the API key that will be provided to you and that's all. All settings and expenses for 3d party providers Mycelium SDK will take on it. For more information, check the
Cloud versionsection
Self hosted version is available out of this repo and can be used by anyone by cloning the repo and settings up all necessary and required SDK parameters. Self hosted version has only one integrated protocol that can be used for yield opportunities recommendations - Spark. To start working with a self hosted SDK version, please refer to the Get started section
Cloud version is a paid (current free) version of the SDK, when everything is handled under the hood for an integrator. The only thing that you need to pass to the SDK during the initialization is an API key. All further 3d party platforms integrations will be handled under the hood by Mycelium. To start working with a self hosted SDK version, please refer to the Get started section
Both cloud and self hosted version are required the following prerequisites:
- pnpm >= 10.9.0
- node >= 22.11.0
- TypeScript >= 5.0.0
Both self hosted and cloud version are required some variables to be provided during the initialization of an SDK. The list of envs for cloud version is significant, than for a self hosted one. Here is the full list of variables:
| Variable Name | Description | Version | Mandatory |
|---|---|---|---|
PRIVY_APP_ID |
Privy wallet app id for embedded wallets | Self-hosted | Yes |
PRIVY_APP_SECRET |
Privy wallet app secret for embedded wallets | Self-hosted | Yes |
RPC_URL |
A RPC URL for a chain | Self-hosted | Yes |
BUNDLER_URL |
A bundler URL to process User Operations | Self-hosted | Yes |
COINBASE_CDP_API_KEY_ID |
Coinbase CDP Api Key ID for on/off ramp functionality | Self-hosted | No |
COINBASE_CDP_API_KEY_SECRET |
Coinbase CDP Api secret for on/off ramp functionality | Self-hosted | No |
INTEGRATOR_ID |
Unique integrator ID to track SDK usage and enable 3rd party services (e.g., Coinbase off/on-ramp) | Self-hosted | Yes |
API_KEY |
API key to run SDK with managed settings | Cloud | Yes |
PROTOCOL_RISK_LEVEL |
Risk level of protocol that will be used by an SDK in the configuration | Cloud & self-hosted | Yes |
CHAIN_ID |
Chain ID to work with | Cloud & self-hosted | Yes |
- Clone the repo:
git clone https://github.com/MyceliumSDK/mycelium-sdk.git- Go to
package/sdkand install dependencies:
cd package/sdk && pnpm install- Build the SDK:
pnpm run buildThe built SDK can then be used in your application or imported as a local library
To test the SDK you can use the build in CLI from the same repository:
- Go to
packages/cliand install dependencies
cd packages/cli && pnpm install-
Setup the CLI settings based on the README.md file
-
Start the CLI
pnpm run startIn case if you want to test the SDK with a fork, you need to use
anvilandpackages/blockchainservice. Please refer topackages/blockchain/README.mdfor more details
In case of a self hosted version, you need to define all your env variables. For more details, please refer the Environment variables section above. Right after you define all env variables, you can initiate the SDK:
this.sdk = new MyceliumSDK({
walletsConfig: {
embeddedWalletConfig: {
provider: {
type: 'privy',
providerConfig: {
appId: '...',
appSecret: '...',
},
},
},
smartWalletConfig: {
provider: {
type: 'default',
},
},
},
chain: {
chainId: '...',
rpcUrl: '...',
bundlerUrl: '...',
},
protocolsRouterConfig: {
riskLevel: '...',
},
coinbaseCDPConfig: {
apiKeyId: '...',
apiKeySecret: '...',
},
integratorId: '...',
});If you decided to use a ready to use library, you need to receive an API key first. For this purpose, you can contact Mike Krupin on Telegram or you can send an email to the Mycelium mailbox
Right after you would get an API key, you can start working with an SDK
- Install the library:
pnpm install @mycelium-sdk/core- You're ready to use and SDK!
To test the SDK you can use the build in CLI from the repository:
- Clone the repo:
git clone https://github.com/MyceliumSDK/mycelium-sdk.git- Go to
packages/cliand install dependencies
cd packages/cli && pnpm install-
Setup the CLI settings based on the README.md file
-
Instal the latest SDK version:
pnpm install @mycelium-sdk/core- Start the CLI
pnpm run startIn case if you want to test the SDK with a fork, you need to use
anvilandpackages/blockchainservice. Please refer topackages/blockchain/README.mdfor more details
this.sdk = await MyceliumSDK.init({
apiKey,
chainId: '8453',
protocolsSecurityConfig: {
riskLevel: 'low',
},
});To get more information about
protocolSecurityConfigsettings, please refer to theProtocol security configsection below
Current config of settings used by Protocol router to define:
- What protocols will be used by SDK
- What savings vaults will be recommended by SDK
Currently, the following settings for the config are available:
riskLeveldefine the risk level of a protocol that will be used by an integrator to recommend saving vaults Risk level is determined by the general popularity and reputation of the protocol within the crypto industry. No independent risk assessment is performed by the SDK to determine the risk level
Currently, the following list of protocols is integrated into SDK and can be used by user in self-hosted and cloud versions:
| Protocol | Chain | ChainId | Protocol risk level | Available on |
|---|---|---|---|---|
| Spark | Base | 8453 | low | Self hosted version only |
| Beefy | Base | 8453 | low | Cloud version only |
The protocol router mechanism of SDK select the best protocol based on your protocolSecurityConfig settings as well as on other provided settings. The only requirement from an integrator is to define a high-level settings for protocols, e.g. min APY, protocol risk level, etc
The SDK will use settings and find the best protocol and vault under the hood. No one, including integrator, will need to care about this part
More protocol and chains will be added soon
The chain configuration provided during SDK initialization defines where on-chain activities will take place. Currently, only one chain is supported for the earn functionality, with multi-chain support coming soon
The example configuration above uses Base chain (chain ID: 8453), meaning all protocol operations and vault deposits will occur on the Base network
Install dependencies:
pnpm installBuild the SDK in watch mode:
pnpm run watchRun tests:
pnpm run testRun tests in watch mode:
pnpm run test:watchThe SDK should be documented and described with TypeDoc rules. To get more context, check CONTRIBUTION.md
To generate documentation:
# Generate public documentation
pnpm run docs:public
# Generate development documentation
pnpm run docs:devCheck the CONTRIBUTION.md
This project is licensed under the dual license - Apache 2.0 + Commercial - see the LICENSE