main
cyhhao 2 years ago
parent 3c7423eabf
commit 250dba3e98

@ -0,0 +1,42 @@
//SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.0;
contract Git3NameService {
mapping(string => address) public nameHub;
mapping(string => address) public nameOwner;
string[] public nameList;
mapping(address => mapping(string => string)) public HubRecords;
constructor() {}
modifier onlyHubOwner(string memory name) {
require(nameOwner[name] == msg.sender, "Only name owner can do this");
_;
}
function registerHub(string memory name, address hub) public {
require(nameHub[name] == address(0), "Name already registered");
nameHub[name] = hub;
nameOwner[name] = msg.sender;
nameList.push(name);
}
function nameListLength() public view returns (uint256) {
return nameList.length;
}
function rebindHubAddress(
string memory name,
address hub
) public onlyHubOwner(name) {
nameHub[name] = hub;
}
function transferNameOwner(
string memory name,
address newOwner
) public onlyHubOwner(name) {
nameOwner[name] = newOwner;
}
}

@ -0,0 +1,31 @@
import { ethers } from "hardhat";
async function main() {
let provider = ethers.provider;
let [operator] = await ethers.getSigners();
let nonce = await operator.getTransactionCount();
console.log(operator.address, nonce, await operator.getBalance());
let price = await provider.getFeeData();
let net = await provider.getNetwork();
console.log(price, net.chainId);
const Nameservice = await ethers.getContractFactory("Git3NameService");
const ns = await Nameservice.deploy({
nonce: nonce,
type: 2,
maxFeePerGas: price.maxFeePerGas!,
maxPriorityFeePerGas: price.maxPriorityFeePerGas!,
});
let receipt = await ns.deployed();
console.log(receipt.deployTransaction.hash);
console.log("NS Contract", ns.address);
}
// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
Loading…
Cancel
Save