
Security News
CISA Rebuffs Funding Concerns as CVE Foundation Draws Criticism
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
@dcspark/adalib
Advanced tools
Cardano friendly API
Adalib implements a Connector
interface that complies with WalletConnect's standards.
It attempts to closely emulate the CIP-30 standard within the connectors. A dapp developer can use these connectors to retrieve the enabled CIP-30 API, and benefit from the included typings this library provides.
You will need a Walletconnect Project ID to use this library. You can get one by signing up and registering a dapp at https://walletconnect.com/.
For an examples, see App.tsx
and Home.tsx
in example project in this repo.
For further docs, see docs.
The init function needs to be called to prepare adalib
to be able to call all
the functions in its API.
import {
init,
cardanoMainnetWalletConnect,
FlintConnector,
WalletConnectConnector
} from 'adalib'
init(
{
// The different connector methodologies that will be used.
// FlintConnector will interact with injected Flint Wallet using browser
// extension, while WalletConnectConnector can be used to interact with all
// wallets that support the WalletConnect protocol.
connectors: [
new FlintConnector(),
new WalletConnectConnector({
relayerRegion: 'wss://relay.walletconnect.com',
metadata: {
description: 'Test app for adalib',
name: 'Test Adalib dApp',
icons: ['https://avatars.githubusercontent.com/u/37784886'],
url: 'http://localhost:3000'
},
autoconnect: true,
qrcode: true
})
],
// Name of the connector to be used.
// The connector needs to be registered in the connectors field above.
// This can be switched later using `switchConnector` function.
connectorName: WalletConnectConnector.connectorName(),
// The name of the chain and network to use.
// Here, `mainnet` refers to the cardano mainnet network.
chosenChain: cardanoMainnetWalletConnect()
},
WALLETCONNECT_PROJECT_ID
)
The connect function can be used to connect a wallet to a dApp. The wallet
chosen needs to be configured in the init
function above.
import { connect, getActiveConnector } from 'adalib'
const address = await connect()
// OR
getActiveConnector()
.enable()
.then(api => {
console.log('CIP-30 API Created', { api });
// Store the enabled CIP-30 api in state and make subsequent calls to it
setEnabledAPI(api);
});
Instead of retrieving the address once on the connect function, one can globally
watch address changes using the watchAddress
API.
import { watchAddress, connect } from 'adalib'
watchAddress(address => {
console.log({ address })
})
// calls `enable` on the active connector
connect()
import { switchConnector, FlintConnector, connect } from 'adalib'
switchConnector(FlintConnector.connectorName)
const flintWalletAPI = await connect()
Example app written in react, for testing in the adalib-example folder.
FAQs
Cardano development utilities and wrappers
We found that @dcspark/adalib demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 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
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
Product
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.
Product
Module Reachability filters out unreachable CVEs so you can focus on vulnerabilities that actually matter to your application.