anduro-wallet-connector-react 1.0.0
Install from the command line:
Learn more about npm packages
$ npm install @anduroproject/anduro-wallet-connector-react@1.0.0
Install via package.json:
"@anduroproject/anduro-wallet-connector-react": "1.0.0"
About this version
Anduro Wallet Connector is a React library that will enable users to easily connect to the Anduro Wallet browser extension. This library includes the below options:
- Connect
- Disconnect
- Send transaction ( BTC & CBTC )
- Asset creation
- Asset transfer
- Mint transfer
- Convert ( BTC to CBTC )
- Convert ( CBTC to BTC)
- Sign
See our Examples for anduro wallet connector react library integration and implementations.
Since the chrome extension is not published. please do below steps temporarily to connect wallet from your browser
- Unzip the wallet file. (Anduro-Wallet.zip)
- Go to your browser (e.g., Chrome).
- Click manage extensions.
- Enable developer mode.
- Click Load Unpacked
- Open(import) the unzipped Anduro-Wallet directory.
- Now you can see the Anduro wallet extension in your browser
- Copy Anduro wallet Extension id from your Manage extension
- Replace with EXTENSION_ID in below Anduro wallet url
chrome-extension://<EXTENSION_ID>/index.html
- Go to example/react/src/config/walletApi.ts
- Replace WALLETURL with your browser wallet url
- Go to example/next-js/src/app/config/config.ts
- Replace WALLETURL with your browser wallet url
- go to example folder and run below command
npm install
Initialize Anduro Wallet Connector with your wallet extension id via the options parameter:
import { UseConnectorProvider } from 'anduro-wallet-connector';
import React from 'react';
function App () {
return (
<UseConnectorProvider walletURL={Anduro wallet url}/>
);
}
we will use the component to connect anduro wallet extension.
Connect Anduro wallet using connect function.
Parameter
chainId: 1 or 2 or 3 or 4
- 1 for Bitcoin mainnet
- 2 for Sidechain mainnet
- 3 for Bitcoin testnet
- 4 for Sidechain testnet
import React from 'react';
const { connect } = React.useContext<any>(useConnector);
const handleConnectResponse = async () => {
const result = await connect({
chainId
})
}
Disconnect Anduro wallet using disconnect function.
import React from 'react';
const { disconnect } = React.useContext<any>(useConnector);
const handleDisConnectResponse = async () => {
const result = await disconnect()
}
Create Asset in Anduro wallet using create asset function.
Parameters
name: The asset's name
symbol: The asset's symbol
imageUrl: The asset's image URL
supply: The asset's total supply
properties: The asset's trait data
assetType:
- 0 for creating tokens.
- 1 for creating NFT.
transactionType: transactionType: create OR mint
receiverAddress: (Optional) Required for mint transactions assetId: (Optional) Required for mint transactions
import { useConnector } from 'anduro-wallet-connector';
import React from 'react';
const {createasset} = React.useContext<any>(useConnector);
const handleCreateAssetAction = async () => {
const result = await createasset({
name: "Anduro",
symbol: "Anduro",
imageUrl: "https://anduro.png/",
supply: 100,
properties: [{type: "#1 Type", value: "#1 Value"}],
assetType: 0,
transactionType: "create",
receiverAddress: "ccrt1qy6302x6qm8084tfwuf2hagfe8ndvpevg3u5n2j",
assetId: 1,
})
}
Create Asset transfer in anduro wallet using transfer asset function
Parameters
assetId: The asset ID
receiverAddress: Receiver Address
supply: supply to transfer
import { useConnector } from 'anduro-wallet-connector';
import React from 'react';
const { transferasset } = React.useContext<any>(useConnector);
const handleTransferFunction = async () => {
const result = await transferasset({
assetId: 1,
receiverAddress: "ccrt1qy6302x6qm8084tfwuf2hagfe8ndvpevg3u5n2j",
supply: 10,
})
}
We provide network and wallet information
import { useConnector } from 'anduro-wallet-connector';
import React from 'react';
const { networkState, walletState } = React.useContext<any>(useConnector);
Parameters
transactionType:
1.normal - Send BTC / CBTC
2.pegin - Convert BTC to CBTC ,
3.pegout - Convert CBTC to BTC
amount: transaction amount.
receiverAddress: (Optional) Receiver address ( Sidechain address / bitcoin address )
feeRate: (Optional) Fee rate per virtual byte
import { useConnector } from 'anduro-wallet-connector';
import React from 'react';
const { send } = React.useContext<any>(useConnector);
const handleSendAction = async () => {
const params = {
transactionType: "normal",
amount: 1,
receiverAddress: "ccrt1qy6302x6qm8084tfwuf2hagfe8ndvpevg3u5n2j",
feeRate: 1,
}
const result = await send(params);
}
Sign Anduro wallet using sign function.
Parameter
message: Message
import React from 'react';
const { sign } = React.useContext<any>(useConnector);
const handleConnectResponse = async () => {
const result = await sign({
message: "sign message"
})
}
Details
- anduro-wallet-connector-react
- AnduroProject
- 8 months ago
- 14 dependencies
Assets
- anduro-wallet-connector-react-1.0.0.tgz
Download activity
- Total downloads 1
- Last 30 days 0
- Last week 0
- Today 0