# ascai-trx

> Ascai - smart contract analysis using AI

Latest version **1.3.9** (published 2023-10-05) · ISC license · 0 weekly downloads

## Install

```sh
npm install ascai-trx
pnpm add ascai-trx
yarn add ascai-trx
bun add ascai-trx
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.9 |
| Published | 2023-10-05 |
| First published | 2023-09-21 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 530.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | zerogravityexplorer |
| Maintainers | moonexplorer |

## Links

- npm: https://www.npmjs.com/package/ascai-trx
- npm.io page: https://npm.io/package/ascai-trx

## Dependencies (3)

- [axios](https://npm.io/package/axios.md) ^1.5.0
- [ethers](https://npm.io/package/ethers.md) ^5.7.2
- [prop-types](https://npm.io/package/prop-types.md) ^15.7.2

## Recent versions

- 1.3.9 (latest) — 2023-10-05
- 1.3.8 — 2023-10-05
- 1.3.7 — 2023-10-05
- 1.3.6 — 2023-10-05
- 1.3.5 — 2023-10-05
- 1.3.4 — 2023-10-04
- 1.3.3 — 2023-10-04
- 1.3.2 — 2023-10-03
- 1.3.1 — 2023-10-03
- 1.3.0 — 2023-10-02
- 1.2.0 — 2023-10-02
- 1.1.0 — 2023-09-27
- 1.0.0 — 2023-09-21

## README

# ascai-trx

![npm version](https://img.shields.io/npm/v/ascai-trx.svg?style=flat-square)

## Overview

ascai-trx is a JavaScript library for enhancing the security of smart contract interactions on the Ethereum blockchain. It leverages AI-powered natural language processing (NLP) to provide an extra layer of security by analyzing smart contracts before transaction execution. This analysis helps users make informed decisions about whether to proceed with a contract interaction.

## Installation

**You can install ascai-trx using npm or yarn:**

    npm  install  ascai-trx

    ## OR

    yarn  add  ascai-trx

## Usage

**To use ascai-trx in your project, follow these steps:**

**Import the Ascai component:**

    import  Ascai  from  "ascai-trx";

**Create a state variable to store your contract data:**

    import  {  useState  }  from  "react";



    const [data, setData]  =  useState({

    contractAddress:  "0x8048ae8cDadA2A466B38679e41b42f613F3912F2",

    signer:  "",  //  Set  your  signer

    functionName:  "set",  //  The  function  you  want  to  call

    inputValue:  "",  //  The  input  value  for  the  function

    params:  {

    value:  0,  //  Value  in  Wei

    gasLimit:  100000,  //  Gas  limit  for  the  transaction

    },

    contractAbi:  storeMyNumberAbi,  //  Your  contract's ABI

    });

**Add the <Ascai> component:**

    <Ascai

    contractAddress={data.contractAddress}

    signer={data.signer}

    functionName={data.functionName}

    inputValue={data.inputValue}

    params={data.params}

    contractAbi={data.contractAbi}

    />

**update your existing button with**

    <button type="submit" onClick={customFunction}></button>

**Add this custome function to your component**

    const customFunction = () => {
        const btn = document.getElementById("ascai-btn");
        btn.click();
    };

Now, when the user clicks the "Submit" button, a popup will open, showing the AI-powered NLP analysis of the smart contract. Users can review the analysis and decide whether to proceed with the contract interaction.

If the user chooses to proceed, the transaction will be executed using the specified contract data and function.

You can also handle the result of the transaction using event listeners or other mechanisms as needed.

### Example

    import React, { Children, useEffect, useState } from    "react";
    import { sendTransactionDetails } from "ascai-trx";
    import Ascai from "ascai-trx";
    import storeMyNumberAbi from "./StoreMyNumber.json";
    import { ethers } from "ethers";

    function ContractInteractionForm() {
    const [cdnEndpoint, setCdnEndpoint] = useState("");
    const [result, setResult] = useState([]);
    const [showPopup, setPopup] = useState(false);

    const [data, setData] = useState({
    contractAddress: "0x8048ae8cDadA2A466B38679e41b42f613F3912F2",
    signer: "",
    functionName: "set",
    inputValue: "",
    params: {
    value: 0,
    gasLimit: 100000,
    },
    contractAbi: storeMyNumberAbi,
    });
    const handleSendTransaction = async () => {
    try {
    if (window.ethereum) {
    const ethereumProvider = new ethers.providers.Web3Provider(
        window.ethereum
    );
    await window.ethereum.enable(); // Request user permission to connect
    let signer = ethereumProvider.getSigner();
    console.log(signer);
    setData({
        ...data,
        signer: signer,
        inputValue: [25],
    });
    }
    } catch (error) {
    console.log("error", error);
    }
    };

    const customFunction = () => {
    const btn = document.getElementById("ascai-btn");
    btn.click();
    };
    useEffect(() => {
    handleSendTransaction();
    }, []);
    return (
    <div>
    {/* {result ? result : null} */}
    <button type="submit" onClick={customFunction}>
    Register
    </button>
    <Ascai
    contractAddress={data.contractAddress}
    signer={data.signer}
    functionName={data.functionName}
    inputValue={data.inputValue}
    params={data.params}
    contractAbi={data.contractAbi}
    />
    </div>
    );
    }

    export default ContractInteractionForm;

### Conclusion

Congratulations! You've successfully integrated and used the ascai-trx library in your project. This added security layer, powered by AI analysis, enhances the safety of your smart contract interactions. If you have any questions or encounter any issues, please refer to the documentation or reach out to our support team.

For more information and detailed documentation, visit our [GitHub repository](https://github.com/Zerogravy/Ascai-Tron/tree/main/ascai-trx).

This example demonstrates how to integrate ascai-trx into a React component. Users can now analyze the smart contract using AI-powered NLP before proceeding with the transaction, adding an extra layer of security to their interactions.

---
_Source: https://npm.io/package/ascai-trx · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
