published by 34r7h
cardano-web3.js
Cardano Web3 JavaScript Library with Crypto, Explorer, Websockets, Contract, Connector modules
Demo: https://ray-network.github.io/cardano-web3.js/
🚀 SDK development is in progress and still in alpha. Not recommended for use in production
API Reference
To Do
Initialization (Simple Demo)
import CardanoWeb3 from "../cardano-web3-browser"
const Cardano = new CardanoWeb3({
crypto: {
network: "testnet",
},
explorer: {
url: "https://graphql-api.mainnet.dandelion.link",
},
})
Cardano.init().then(() => {
console.log(Cardano.crypto)
console.log(Cardano.explorer)
async function getAccountState() {
const mnemonic = await Cardano.crypto.generateMnemonic()
const { privateKey, publicKey } = await Cardano.crypto.getAccountKeys(mnemonic)
const { assets, transactions, utxos } = await Cardano.explorer.getAccountStateByPublicKey(publicKey, 25, 10, [0, 1])
console.log('accountBalance', assets)
console.log('accountTransactions', transactions)
console.log('accountUtxos', utxos)
}
getAccountState()
})
Lib state
Cardano.version
Cardano.initialized
Cardano.settings
Crypto (Working with Cardano Crypto Entities)
Cardano.crypto.Cardano
Cardano.crypto.Bech32
Cardano.crypto.Bip39
Cardano.crypto.BigNumber
Cardano.crypto.Network
Cardano.crypto.Utils
Cardano.crypto.generateMnemonic()
Cardano.crypto.validateMnemonic(mnemonic)
Cardano.crypto.validateAddress(address)
Cardano.crypto.getAccountKeys(mnemonic)
Cardano.crypto.getAccountAddresses(pubKey, pageSize, [addressTypes], shift)
Cardano.crypto.generatePolicyForPubkey(pubKey)
Cardano.crypto.txBuildMint(toAddress, tokensToMint, utxos, currentSlot, metadata, donate)
Cardano.crypto.txBuildAll(toAddress, utxos, currentSlot, metadata)
Cardano.crypto.txBuild(outputs, utxos, changeAddress, currentSlot, metadata, certificates, withdrawals, allowNoOutputs)
Cardano.crypto.txSign(transaction, privateKey, script)
Cardano.crypto.generateDelegationCerts(pubKey, hasKey, poolId)
Cardano.crypto.generateDeregistrationCerts(pubKey)
...
Explorer (Cardano-graphql Query Wrappers)
Cardano.explorer.query(query)
Cardano.explorer.getNetworkInfo()
Cardano.explorer.getAccountStateByPublicKey(pubKey, pageSize, maxShiftIndex, [addressTypes])
Cardano.explorer.txSend(transaction)
...
Websockets (Ogmios Interactions)
...
Contract (Smart Contracts Interactions)
...
Connector (Web3 Events & Listeners)
...