npx hardhat run scripts/deploy.js--network goerli,成功粘贴已编译的2个Solidity文件
我的硬盘.config.js
require('@nomiclabs/hardhat-waffle');
module.exports = {
solidity: '0.8.9',
networks: {
goerli: {
url: 'my address',
accounts: ['my key'],
},
},
};
我的deploy.js
const main = async () => {
const transactionsFactory = await hre.ethers.getContractFactory("Transactions");
const transactionsContract = await transactionsFactory.deploy();
await transactionsContract.deployed();
console.log("Transactions address: ", transactionsContract.address);
};
const runMain = async () => {
try {
await main();
process.exit(0);
} catch (error) {
console.error(error);
process.exit(1);
}
};
runMain();
我的交易.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.9;
import "hardhat/console.sol";
contract Transactions {
uint256 transactionCount;
event Transfer(address from, address receiver, uint amount, string message, uint256 timestamp, string keyword);
struct TransferStruct {
address sender;
address receiver;
uint amount;
string message;
uint256 timestamp;
string keyword;
}
TransferStruct[] transactions;
function addToBlockchain(address payable receiver, uint amount, string memory message, string memory keyword) public {
transactionCount += 1;
transactions.push(TransferStruct(msg.sender, receiver, amount, message, block.timestamp, keyword));
emit Transfer(msg.sender, receiver, amount, message, block.timestamp, keyword);
}
function getAllTransactions() public view returns (TransferStruct[] memory) {
return transactions;
}
function getTransactionCount() public view returns (uint256) {
return transactionCount;
}
}
有人知道解决办法吗?
我试图删除缓存文件夹,但仍然不起作用,我还更改了solidity版本,不起作用
我找到了解决方案,你需要增加你的余额,然后你的天然气就会增加,问题是因为我的余额很低,所以我的天然气很低