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.
npm install like-js-interface
yarn add like-js-interface
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)
}
})()