like-js-interface
v1.4.0
Published
Like Search smart contract JavaScript API
Downloads
1
Maintainers
Readme
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)
}
})()