dgen-base-sdk
v0.2.1
Published
React Native wrapper for Ethereum Phone WalletSDK (Android)
Downloads
13
Maintainers
Readme
dgen-base-sdk
React Native wrapper for the Android WalletSDK used on Ethereum Phone custom OS.
- Uses WalletSDK from JitPack (currently
b50e1fa116) - Exposes a simple JS API with autolinking on Android
- Includes OS detection and custom gas estimation via bundler RPC
Install
npm install dgen-base-sdk
# or
yarn add dgen-base-sdkAndroid will autolink. Ensure your app-level repositories include JitPack (RN 0.72+ projects typically do). If not, add to your root android/build.gradle:
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}Usage
import {
initialize,
isRunningOnDgen,
getAddress,
sendTransaction,
getChainId,
signMessage,
} from 'dgen-base-sdk';
await initialize('https://your-bundler.example'); // bundler RPC for gas estimation & submission
const onCustomOS = await isRunningOnDgen();
if (!onCustomOS) {
// Fallback or inform user
}
const address = await getAddress();
const chainId = await getChainId();
const txHash = await sendTransaction(
'0xRecipient',
'0',
'0x',
);
const sig = await signMessage('hello', chainId);API
initialize(bundlerRpcUrl: string): Promise<void>isRunningOnDgen(): Promise<boolean>// true if Platform is Android andgetSystemService("wallet")existsisWalletConnected(): Promise<boolean>isEthOS(): Promise<boolean>getAddress(): Promise<string>getPair(): Promise<{ x: string; y: string } | null>getPrecomputedAddress(pubKeyX: string, pubKeyY: string, salt?: string): Promise<string>encodeSignatureData(r: string, s: string): Promise<string>// returns 0x-prefixed hexencodeInitCode(factoryAddress: string, owners: string[], nonce: string): Promise<string>getGasPrice(bundlerRpcUrl: string): Promise<{ maxFeePerGas: string; maxPriorityFeePerGas: string }>getNonce(senderAddress: string, rpcEndpoint?: string): Promise<string>getChainId(): Promise<number>changeChain(chainId: number, rpcEndpoint: string, bundlerRpcUrl: string): Promise<string>signMessage(message: string, chainId: number, type?: string): Promise<string>sendTransaction(to: string, value: string, data: string, callGas?: string, chainId?: number, rpcEndpoint?: string): Promise<string>sendBatchTransaction(txParamsList: { to: string; value: string; data: string }[], callGas?: string, chainId?: number, rpcEndpoint?: string, bundlerRpcUrl?: string): Promise<string>isDeployed(address: string): Promise<boolean>sendUserOpToBundler(userOp: UserOperation): Promise<string>
Notes:
- Big integers are accepted/returned as strings. Hex strings should be 0x-prefixed.
- Android only. On iOS,
isRunningOnDgen()returnsfalseand other methods are not available. - Gas estimation: the library constructs a dummy-signed UserOperation and calls
eth_estimateUserOperationGason your bundler RPC. It uses exactpreVerificationGasandcallGasLimitreturned by the API and fixes verificationGasLimit to 800k (pre-doubled to 400k before WalletSDK’s internal doubling).
Requirements
- Android minSdk 24
- React Native >= 0.72 (tested on 0.82)
- JDK 17 for Android builds
License
MIT
