npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

aelf-smartcontract-viewer

v1.0.10

Published

A React component to view and interact with Aelf smart contracts

Downloads

362

Readme

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:

npm install aelf-smartcontract-viewer

Usage

Basic Example

import React from "react";
import { ContractView } from "aelf-smartcontract-viewer";

const App = () => {
  return (
    <div>
      <ContractView
        address="your_smart_contract_address"
        rpcUrl="rpc_url" // i.e = https://explorer-test-side02.aelf.io/chain
        contractName="Smart Contract Name"
      />
    </div>
  );
};

export 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.

import React from "react";
import { ContractView } from "aelf-smartcontract-viewer";
import AElf from "aelf-sdk";

const App = () => {
  const wallet = AElf.wallet.getWalletByPrivateKey("YOUR_PRIVATE_KEY");

  return (
    <div>
      <ContractView
        wallet={wallet}
        address="your_smart_contract_address"
        rpcUrl="rpc_url" // i.e = https://explorer-test-side02.aelf.io/chain
        contractName="Smart Contract Name"
      />
    </div>
  );
}

export 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.