Installations
npm install aelf-smartcontract-viewer
Developer Guide
Typescript
Yes
Module System
ESM
Node Version
20.16.0
NPM Version
10.8.1
Score
48.3
Supply Chain
60.5
Quality
79.8
Maintenance
100
Vulnerability
93.4
License
Releases
Unable to fetch releases
Love this project? Help keep it running โ sponsor us today! ๐
Download Statistics
Total Downloads
1,105
Last Day
1
Last Week
17
Last Month
101
Last Year
1,105
Bundle Size
210.21 kB
Minified
23.37 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.1.1
Package Id
aelf-smartcontract-viewer@1.1.1
Unpacked Size
663.59 kB
Size
116.15 kB
File Count
5
NPM Version
10.8.1
Node Version
20.16.0
Publised On
27 Nov 2024
Total Downloads
Cumulative downloads
Total Downloads
1,105
Last day
-66.7%
1
Compared to previous day
Last week
30.8%
17
Compared to previous week
Last month
32.9%
101
Compared to previous month
Last year
0%
1,105
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
13
aelf-smartcontract-viewer
The aelf-smartcontract-viewer is a React component that provides an easy interface to view and interact with smart contracts on the Aelf blockchain. You can use this component to input contract details and view available read and write methods. This tool is useful for developers building applications around Aelf smart contracts, allowing easy testing and interaction with deployed contracts.
Installation
You can install the package using npm:
1npm install aelf-smartcontract-viewer
Usage
Basic Example
1import React from "react"; 2import { ContractView } from "aelf-smartcontract-viewer"; 3 4const App = () => { 5 return ( 6 <div> 7 <ContractView 8 address="your_smart_contract_address" 9 rpcUrl="rpc_url" // i.e = https://explorer-test-side02.aelf.io/chain 10 contractName="Smart Contract Name" 11 /> 12 </div> 13 ); 14}; 15 16export default App;
Props
Prop | Type | Default | Description |
---|---|---|---|
wallet | IWalletInfo | undefined | Optional wallet info. If not provided, a new wallet is generated. |
headerTitle | string | "Aelf Contract View" | Title for the contract view header. |
headerShown | boolean | true | Whether the header should be shown or not. |
address | string | undefined | Address of the contract. If not provided, a default contract address is fetched from the Aelf blockchain. |
contractName | string | "Contract" | The name of the contract to be displayed. |
rpcUrl | string | "https://explorer-test-side02.aelf.io/chain" | The RPC URL to connect to the Aelf blockchain. |
theme | light or dark | "light" | Theme of contract view component |
Example Explanation
The above example demonstrates how to use the ContractView
component. You only need to pass in the contract's address, RPC URL, and optionally the contract name.
Smart Contract Interaction
The ContractView
component displays the available read and write methods from the given smart contract. Once loaded, the methods are grouped as follows:
- Read Methods: These are functions you can call to read data from the contract without sending a transaction.
- Write Methods: These are functions that will initiate a blockchain transaction to update the state of the contract.
Example with Wallet
If you want to specify your own wallet, you can pass the wallet
prop. If you donโt provide a wallet, the component will create a new wallet for you and interact with the blockchain using that.
1import React from "react"; 2import { ContractView } from "aelf-smartcontract-viewer"; 3import AElf from "aelf-sdk"; 4 5const App = () => { 6 const wallet = AElf.wallet.getWalletByPrivateKey("YOUR_PRIVATE_KEY"); 7 8 return ( 9 <div> 10 <ContractView 11 wallet={wallet} 12 address="your_smart_contract_address" 13 rpcUrl="rpc_url" // i.e = https://explorer-test-side02.aelf.io/chain 14 contractName="Smart Contract Name" 15 /> 16 </div> 17 ); 18} 19 20export default App;
Features
- Auto Wallet Creation: If no wallet is provided, the component creates a new wallet.
- RPC URL Management: Users can select different RPC URLs for connecting to different blockchain networks.
- Contract Method Interaction: The component lists both read and write methods available on the contract, allowing for easy interaction.
Contributing
We welcome contributions to this project. If you find any bugs or want to add new features, feel free to submit a pull request or open an issue on the GitHub repository.
No vulnerabilities found.
No security vulnerabilities found.