Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
@coinbase/cbpay-js
Advanced tools
The Coinbase Pay JS SDK provides a fiat onramp experience for approved partners. Wallet providers and dapps can leverage Coinbase Pay and let their users top up their self-custody wallets.
The Coinbase Pay JS SDK provides a fiat onramp experience for approved partners. Wallet providers and dapps can leverage Coinbase Pay and let their users top up their self-custody wallets.
See the Coinbase Pay documentation for configuration options. Developers interested in using Coinbase Pay will need to contact the Coinbase Pay team to get their domains/extension IDs added to the Coinbase Pay allowlist. Please contact the Coinbase Pay team by filling this form and selecting “Coinbase Pay SDK” in the product dropdown menu.
With yarn
:
yarn add @coinbase/cbpay-js
With npm
:
npm install @coinbase/cbpay-js
The package is distributed as both ESModules and CommonJS. To use the CommonJS output, the regenerator-runtime
package will also need to be installed:
With yarn
:
yarn add regenerator-runtime
With npm
:
npm install regenerator-runtime
import { initOnRamp } from '@coinbase/cbpay-js';
const options = {
appId: 'your_app_id',
widgetParameters: {
destinationWallets: [{
address: '0xabc123',
blockchains: ['ethereum', 'avalanche-c-chain'],
}],
},
closeOnExit: true,
closeOnSuccess: true,
embeddedContentStyles: {
target: '#target-area',
},
onExit: () => {
alert('On Exit');
},
onSuccess: () => {
alert('On Success');
},
onEvent: (metadata) => {
console.log(metadata);
},
}
// Initialize the CB Pay instance
let onrampInstance;
const instance = initOnRamp(options, (error, instance) => {
onrampInstance = instance;
});
// Open the widget when the user clicks a button
onrampInstance.open();
// When button unmounts destroy the instance
onrampInstance.destroy();
import type { CBPayInstanceType, InitOnRampParams } from '@coinbase/cbpay-js';
import { initOnRamp } from '@coinbase/cbpay-js';
const PayWithCoinbaseButton: React.FC = () => {
const [onrampInstance, setOnrampInstance] = useState<CBPayInstanceType | undefined>();
useEffect(() => {
initOnRamp({
appId: 'your_app_id',
widgetParameters: {
destinationWallets: [
{
address: '0xabc123',
blockchains: ['ethereum', 'avalanche-c-chain'],
},
],
},
onSuccess: () => {
console.log('success');
},
onExit: () => {
console.log('exit');
},
onEvent: (event) => {
console.log('event', event);
},
experienceLoggedIn: 'popup',
experienceLoggedOut: 'popup',
closeOnExit: true,
closeOnSuccess: true,
}, (_, instance) => {
setOnrampInstance(instance);
});
return () => {
onrampInstance?.destroy();
};
}, []);
const handleClick = () => {
onrampInstance?.open();
};
return <Button onClick={handleClick} disabled={!onrampInstance}>Buy with Coinbase</Button>;
};
Commit signing is required for contributing to this repo. For details, see the docs on contributing and commit-signing.
FAQs
The Coinbase Onramp JS SDK contains helper methods to simplify integrating with our fiat onramp. Wallet providers and dapps can leverage Coinbase Onramp and let their users top up their self-custody wallets.
We found that @coinbase/cbpay-js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 12 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.