我使用混合编辑器部署了一个智能契约。我需要知道,如果我必须有安全帽的延伸以及。我希望用户能够使用用户界面设置他们的配置文件,比如可用性、配置文件图片时薪等。在混合中,我已经能够通过在部署智能契约之后添加一个新实例来实现这一点。我不太确定我(或其他人)如何能够使用UI与智能契约交互。我打算使用Moralis和Web3uikit,我也希望图片被上传到IPFS,以及。
发布于 2022-09-24 22:20:29
不,安全帽用于编译、测试和部署智能契约,在您自己的本地hardhat块链实例上,或者在testnet或mainnet上。如果您已经将合同部署到块链中,那么您就不再需要草帽了。
如果您验证了合同,您应该能够通过https://mumbai.polygonscan.com/ >搜索您的合同地址>合同选项卡与其进行交互。
然而,从你的问题中我能理解的是,我认为你需要做的是创建一个网站,作为合同的界面。
发布于 2022-11-07 21:56:47
你不需要戴安全帽。
如果您希望与来自UI的智能契约进行交互,则需要连接应用程序UI中的元询问之类的钱包。使用像etherJs或web3JS这样的JS库,您可以连接智能契约并与之交互。
例如,使用etherjs:
async function payUser (amount){
//connect to metamask
const { ethereum } = window;
//if ethereum is not found, it means that a user does not
//have metamask installed on their browser
if (!ethereum) {
return;
}
//Get wallet provider and signer
const provider = new ethers.providers.Web3Provider(ethereum);
const signer = provider.getSigner();
//contract initialization: create an instance of the //contract
const contractInstance = new ethers.Contract(contractAddress, abi, signer);
//Interact with the contract using appropriate methods
const transaction = await
contractInstance.pay(ethers.utils.parseEther(amount))
}
https://stackoverflow.com/questions/73816094
复制相似问题