like-js-interface
TypeScript icon, indicating that this package has built-in type declarations

1.4.0 • Public • Published

like-js-interface

About Like Search

Like Search is a decentralized search engine based on the Ethereum smart contracts. Users can like a URL, that is, deposit ETH to increase the number of likes of a URL for a keyword. URLs with likes will be displayed in the smart contract results and ranked by the number of likes. Any individual can vote in this way to evaluate the quality of resources.

Installation

NPM

npm install like-js-interface

Yarn

yarn add like-js-interface

Usage

const Web3 = require('web3');
const BN = require('bn.js')
const { Like } = require('like-js-interface');
const providerUrl = "Provider URL";
const contractAddress = "XXX";
const from = "XXX";
(async () => {
    try {
        const web3 = new Web3(providerUrl)
        const like = new Like(web3, contractAddress)
        const keywordId = Like.keywordId("search engine")
        const url = new URL("https://www.like.foundation")
        const amount = new BN(1)
        const likeTran = like.like(keywordId, url, amount)
        const estimatedGas = await likeTran.estimateGas()
        const receipt = await likeTran.send({
            from,
            gas: estimatedGas
        })
        console.log('receipt:', receipt)
    } catch (error) {
        console.error(error)
    }
})()

Package Sidebar

Install

npm i like-js-interface

Weekly Downloads

7

Version

1.4.0

License

BSD-3-Clause

Unpacked Size

402 kB

Total Files

58

Last publish

Collaborators

  • like-foundation