@coinbase/cdp-core
. You’ll learn how to install the package,
initialize the SDK, and make your first API call.
http://localhost:3000
createAccountOnLogin
to "evm-smart"
:
createAccountOnLogin
is set to "evm-smart"
, the SDK will:
viem
to broadcast the transaction.
createCDPEmbeddedWallet
, which exposes a .provider
attribute. createCDPEmbeddedWallet
must be called with the desired chains to support as well as the transports for these chains.
The provider will initially connect to the first chain in the chains
array. The transports are typically HTTP RPC endpoints, which are used internally for broadcasting non-Base transactions. For more information on transports, see Wagmi’s createConfig
setup.
toViemAccount
utility function that enables wrapping an embedded wallet into a Viem account compatible interface. This allows the account to act as a drop-in replacement for any library or framework that accepts Viem accounts.
Parameter | Type | Description |
---|---|---|
cfg | Config | The configuration for the core package. |
Promise
<void
>
Parameter | Type | Description |
---|---|---|
options | SignInWithEmailOptions | The options for the sign in. |
Promise
<SignInWithEmailResult
>
The result of the sign in.
Parameter | Type | Description |
---|---|---|
options | SignInWithSmsOptions | The options for the sign in. |
Promise
<SignInWithSmsResult
>
The result of the sign in.
Parameter | Type | Description |
---|---|---|
options | VerifyEmailOTPOptions | The options for the verification. |
Promise
<VerifyEmailOTPResult
>
The result of the verification.
Parameter | Type | Description |
---|---|---|
options | VerifySmsOTPOptions | The options for the verification. |
Promise
<VerifySmsOTPResult
>
The result of the verification.
Promise
<null
| User
>
The currently signed-in user, or null if no user is signed in.
Promise
<boolean
>
Whether the user is currently signed in.
Promise
<void
>
Promise
<null
| string
>
The access token for the current user, or null if no user is signed in.
Parameter | Type | Description |
---|---|---|
callback | OnAuthStateChangeFn | The callback function to be called when the authentication state changes. |
void
Parameter | Type | Description |
---|---|---|
options | SignEvmHashOptions | The options for the signing. |
Promise
<SignEvmHashResult
>
The result of the signing.
Parameter | Type | Description |
---|---|---|
options | SignEvmTransactionOptions | The options for the signing. |
Promise
<SignEvmTransactionResult
>
The result of the signing.
Parameter | Type | Description |
---|---|---|
options | SendEvmTransactionOptions | The options for the sending. |
Promise
<SendEvmTransactionResult
>
The transaction hash of the sent transaction.
Parameter | Type | Description |
---|---|---|
options | SignEvmMessageOptions | The options for the signing. |
Promise
<SignEvmHashResult
>
The result of the signing.
Parameter | Type | Description |
---|---|---|
options | SignEvmTypedDataOptions | The options for the signing. |
Promise
<SignEvmTypedDataResult
>
The result of the signing.
Parameter | Type | Description |
---|---|---|
options | SendUserOperationOptions | The options for sending the user operation. |
Promise
<SendUserOperationResult
>
Promise that resolves to the user operation hash.
Parameter | Type | Description |
---|---|---|
options | GetUserOperationOptions | The options for getting the user operation. |
Promise
<EvmUserOperation
>
The user operation details.
Parameter | Type | Description |
---|---|---|
options | ExportEvmAccountOptions | The options for the exporting. |
Promise
<ExportEvmAccountResult
>
The result of the export.
Parameter | Type | Description |
---|---|---|
address | `0x${string}` | The EVM address to create a Viem account for |
Promise
<{
}>
A Viem LocalAccount that can sign messages and transactions using CDP’s signing functions
createConfig
setup.
Type Parameter |
---|
chains extends readonly [Chain , Chain ] |
Parameter | Type | Description |
---|---|---|
_parameters | CDPEmbeddedWalletConfig <chains > | Configuration parameters for the connector - see CDPEmbeddedWalletConfig |
CDPEmbeddedWallet
A CDP embedded wallet instance
Error
Parameter | Type |
---|---|
statusCode | number |
errorType | APIErrorType |
errorMessage | string |
correlationId? | string |
errorLink? | string |
cause? | Error |
APIError
object
Property | Type |
---|---|
statusCode | number |
errorType | APIErrorType |
errorMessage | string |
correlationId? | string |
errorLink? | string |
Error
Parameter | Type | Description |
---|---|---|
code | EIP1193ErrorCode | The error code from EIP1193ErrorCode enum. |
message | string | The error message. |
EIP1193ProviderError
Property | Modifier | Type | Description |
---|---|---|---|
code | public | EIP1193ErrorCode | The error code from EIP1193ErrorCode enum. |
EIP712Domain
”, “PermitTransferFrom
”).
Property | Type | Description |
---|---|---|
domain | EIP712Domain | - |
types | EIP712Types | - |
primaryType | string | The primary type of the message. This is the name of the struct in the types object that is the root of the message. |
message | EIP712Message | The message to sign. The structure of this message must match the primaryType struct in the types object. |
Property | Type |
---|---|
email? | EmailAuthentication |
sms? | SmsAuthentication |
Property | Type | Description |
---|---|---|
userId | string | The user ID. |
authenticationMethods | AuthenticationMethods | The authentication methods used by the user. |
evmAccounts? | EvmAddress [] | The EVM accounts associated with the user. |
evmSmartAccounts? | EvmAddress [] | The EVM smart accounts associated with the user. |
Property | Type | Description |
---|---|---|
type | "email" | The type of authentication method. |
email | string | The email address of the user. |
Property | Type | Description |
---|---|---|
type | "sms" | The type of authentication method. |
phoneNumber | string | The phone number of the end user in E.164 format. |
Property | Type |
---|---|
email | string |
Property | Type | Description |
---|---|---|
message | string | The message to display to the user. |
flowId | string | The flow ID to use in verifyEmailOTP. |
Property | Type | Description |
---|---|---|
phoneNumber | string | The phone number of the end user in E.164 format. Example: “+14155552671” |
Property | Type | Description |
---|---|---|
message | string | The message to display to the user. |
flowId | string | The flow ID to use in verifySmsOTP. |
Property | Type | Description |
---|---|---|
flowId | string | The flow ID to use in verifyEmailOTP. |
otp | string | The OTP to verify. |
Property | Type | Description |
---|---|---|
user | User | The successfully logged-in user. |
message | string | The message to display to the user. |
isNewUser | boolean | Whether the user is newly signed up. |
Property | Type | Description |
---|---|---|
flowId | string | The flow ID to use in verifySmsOTP. |
otp | string | The OTP to verify. |
Property | Type | Description |
---|---|---|
user | User | The successfully logged-in user. |
message | string | The message to display to the user. |
isNewUser | boolean | Whether the user is newly signed up. |
Parameter | Type |
---|---|
user | User | null |
void
Property | Type | Description |
---|---|---|
evmAccount | EvmAddress | The EVM account to sign the hash with. |
hash | Hex | The hash to sign. |
Property | Type | Description |
---|---|---|
signature | Hex | The signature. |
Property | Type | Description |
---|---|---|
evmAccount | EvmAddress | The EVM account to sign the message with. |
transaction | AllowedEvmTransactionType | The transaction to sign. |
Property | Type | Description |
---|---|---|
signedTransaction | Hex | The signed transaction. |
Property | Type | Description |
---|---|---|
evmAccount | EvmAddress | The EVM account to send the transaction with. |
network | SendEvmTransactionWithEndUserAccountBodyNetwork | The network to send the transaction to. |
transaction | AllowedEvmTransactionType | The transaction to send. |
Property | Type | Description |
---|---|---|
transactionHash | Hex | The transaction hash. |
Property | Type | Description |
---|---|---|
evmAccount | EvmAddress | The EVM account to sign the message with. |
message | string | The message to sign. |
Property | Type | Description |
---|---|---|
signature | Hex | The signature. |
primaryType
struct in the types
object.
Property | Type | Description |
---|---|---|
evmAccount | EvmAddress | The EVM account to sign the typed data with. |
typedData | EIP712TypedData | The EIP-712 typed data to sign. |
Property | Type | Description |
---|---|---|
to | EvmAddress | The target address for the call. |
value? | bigint | The value to send with the call (in wei). |
data? | Hex | The data to send with the call. |
Property | Type | Description |
---|---|---|
evmSmartAccount | EvmAddress | The EVM Smart Account to send the user operation with. |
network | SendEvmTransactionWithEndUserAccountBodyNetwork | The network to send the user operation on. |
calls | EvmCall [] | The calls to make from the user operation. |
useCdpPaymaster? | boolean | Whether to use the CDP Paymaster for the user operation. |
paymasterUrl? | string | The URL of the paymaster to use for the user operation. Get your free Base paymaster URL from the CDP Portal. |
Property | Type | Description |
---|---|---|
userOperationHash | Hex | The user operation hash. |
Property | Type | Description |
---|---|---|
userOperationHash | Hex | The user operation hash. |
evmSmartAccount | EvmAddress | The EVM Smart Account that sent the user operation. |
network | SendEvmTransactionWithEndUserAccountBodyNetwork | The network the user operation was sent on. |
Property | Type | Description |
---|---|---|
signature | Hex | The signature. |
Property | Type | Description |
---|---|---|
evmAccount | EvmAddress | The EVM account to export. |
Property | Type | Description |
---|---|---|
privateKey | string | The 32 byte raw private key of the EVM account. |
Type Parameter | Default type | Description |
---|---|---|
chains extends readonly [Chain , ...Chain[] ] | readonly [Chain , ...Chain[] ] | The chains to support |
Property | Type | Description |
---|---|---|
chains | chains | - |
transports | Record <chains [number ]["id" ], Transport > | The transports to use for each chain |
announceProvider? | boolean | Whether to announce the provider to the wallet |
Property | Type |
---|---|
provider | EIP1193Provider |
Property | Type |
---|---|
method | "eth_accounts" |
params | [] |
Property | Type |
---|---|
method | "eth_requestAccounts" |
params | [] |
Property | Type |
---|---|
method | "personal_sign" |
params | [`0x${string}` , `0x${string}` ] |
Property | Type |
---|---|
method | "eth_sendTransaction" |
params | SendTransactionRequestParams |
Property | Type |
---|---|
method | "eth_signTypedData_v4" |
params | [EvmAddress , string ] |
Property | Type |
---|---|
method | "eth_sign" |
params | [Hex , EvmAddress ] |
Property | Type |
---|---|
method | "eth_chainId" |
params | [] |
Property | Type |
---|---|
method | "wallet_disconnect" |
params | [] |
Property | Type |
---|---|
method | "wallet_switchEthereumChain" |
params | [{ chainId : string ; }] |
Property | Type |
---|---|
method | "wallet_sendCalls" |
params | [{ calls : Call []; }] |
Property | Type |
---|---|
method | "wallet_getCallsStatus" |
params | [`0x${string}` ] |
Property | Type |
---|---|
method | "wallet_getCapabilities" |
params | [] |
Property | Type |
---|---|
method | string |
params | unknown [] |
Type Parameter | Description |
---|---|
T | The type to make partial. |
Property | Type |
---|---|
chainId | number |
setChainId | (chainId ) => void |
chains | readonly [Chain , ...Chain[] ] |
user | User | null |
setUser | (user ) => void |