Skip to content

Commit

Permalink
Add base network and deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
yutou committed Apr 20, 2024
1 parent e03dbf1 commit f267e59
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 34 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# address

base: 0xd15Ce723Dd04C5e6E245E44e60c545a563A124bB
sepolia: 0xE0B870ffbA7f73d5F757552F3a428DFE73431944

sign base: https://scan.sign.global/schema/onchain_evm_8453_0x15
sign sepolia: https://testnet-scan.sign.global/schema/onchain_evm_11155111_0x7

# deploy

```bash
npx hardhat run scripts/01-deploy.ts --network sepolia
```


- a 发起 对 b 的求婚。a 可以发起多个求婚,但是同时只能有一个生效,第二次发起会把第一次发起的记录给清掉。
- b 可以看到所有对他发起的求婚的地址和信息,并选择其中一个地址进行确认。
- a 和 b 会创建一个 Attestation,之后 a 和 b 都不能再发起求婚或者确认求婚。
5 changes: 5 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ const config: HardhatUserConfig = {
accounts: [process.env.PRIVATE_KEY!, process.env.PRIVATE_KEY2!],
saveDeployments: true,
zksync: false
},
base: {
chainId: 8453,
url: 'https://base.llamarpc.com',
accounts: [process.env.PRIVATE_KEY!, process.env.PRIVATE_KEY2!],
}
},
etherscan: {
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"prettier:write": "prettier --write **/*.{json,md,yml,ts} --ignore-path=.prettierignore",
"test": "forge test",
"test:coverage": "forge coverage",
"test:gas": "forge test --gas-report"
"test:gas": "forge test --gas-report",
"deploy": "npx hardhat run scripts/01-deploy.ts --network base"
},
"author": "",
"license": "ISC",
Expand Down Expand Up @@ -61,4 +62,4 @@
"typechain": "^8.3.2",
"typescript": "~5.0.4"
}
}
}
60 changes: 32 additions & 28 deletions scripts/01-deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,54 +5,58 @@ async function main() {

const [deployer, deployer2] = await ethers.getSigners()



console.log('addressA:', deployer.getAddress())
console.log('addressB:', deployer2.getAddress())

const Factory = await ethers.getContractFactory('MarryMe')
const instance = await Factory.deploy()
const contract = await instance.waitForDeployment()
console.log(await contract.getAddress())

console.log('addressA:', deployer.getAddress())
console.log('addressB:', deployer2.getAddress())

const addressA = await deployer.getAddress();
const addressB = await deployer2.getAddress();
// const addressB = await deployer2.getAddress();

await contract.setSPInstance('0x878c92FD89d8E0B93Dc0a3c907A2adc7577e39c5')
// await contract.setSPInstance('0x878c92FD89d8E0B93Dc0a3c907A2adc7577e39c5') //sepolia
await contract.setSPInstance('0x2b3224D080452276a76690341e5Cfa81A945a985') //base

console.log('setSPInstance done')

await contract.setSchemaID('0x7')
// await contract.setSchemaID('0x7') // sepolia
await contract.setSchemaID('0x15') // base

console.log('setSchemaID done')

// submitProposal
await (await contract.submitProposal(addressB, 'hello world B')).wait()
// // submitProposal
// await (await contract.submitProposal(addressB, 'hello world B')).wait()

console.log('submitProposal done')
// console.log('submitProposal done')

// 查询某个地址发送的所有求婚信息
const proposalSubmitted = await contract.getProposalsSentBy(addressA)
console.log('proposal submit by addressA:', JSON.stringify(proposalSubmitted, null, 2))
// // 查询某个地址发送的所有求婚信息
// const proposalSubmitted = await contract.getProposalsSentBy(addressA)
// console.log('proposal submit by addressA:', JSON.stringify(proposalSubmitted, null, 2))

// 查询某个地址收到的所有求婚信息
const info = await contract.getProposalsReceivedBy(addressB);
console.log('proposal received by addressB:', JSON.stringify(info, null, 2))
// // 查询某个地址收到的所有求婚信息
// const info = await contract.getProposalsReceivedBy(addressB);
// console.log('proposal received by addressB:', JSON.stringify(info, null, 2))

// switch to addressB to accept the proposal
const confirm = await contract.connect(deployer2).confirmProposal(addressA, 'hello world A')
await confirm.wait()
console.log('acceptProposal done:')
// // switch to addressB to accept the proposal
// const confirm = await contract.connect(deployer2).confirmProposal(addressA, 'hello world A')
// await confirm.wait()
// console.log('acceptProposal done:')

// 查询某个地址的婚姻状态,返回 attestationId
const attestationId = await contract.getMarryAttestationId(addressA)
console.log('attestationID:', attestationId);
// // 查询某个地址的婚姻状态,返回 attestationId
// const attestationId = await contract.getMarryAttestationId(addressA)
// console.log('attestationID:', attestationId);

// 查询某个地址的婚姻状态,返回 attestation 详细信息
const attestation = await contract.getMarryAttestation(addressA);
console.log('attestation:', attestation)
// // 查询某个地址的婚姻状态,返回 attestation 详细信息
// const attestation = await contract.getMarryAttestation(addressA);
// console.log('attestation:', attestation)

// 查询某个地址的婚姻状态,返回 true/false
const isMarried = await contract.checkMarried(addressA)
console.log('isMarried:', isMarried)
// // 查询某个地址的婚姻状态,返回 true/false
// const isMarried = await contract.checkMarried(addressA)
// console.log('isMarried:', isMarried)

/**
* output example:
Expand Down

0 comments on commit f267e59

Please sign in to comment.