-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b7a314d
commit 97b2ddb
Showing
7 changed files
with
7,298 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,3 +102,8 @@ dist | |
|
||
# TernJS port file | ||
.tern-port | ||
|
||
|
||
artifacts | ||
cache | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
pragma solidity 0.6.12; | ||
|
||
import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | ||
|
||
contract Token is ERC20 { | ||
bool public synthesis; | ||
uint public created; | ||
address public owner; | ||
|
||
address[] public materials; | ||
uint[] public amounts; | ||
|
||
constructor (string memory name, string memory symbol) public ERC20(name, symbol) { | ||
synthesis = true; | ||
created = block.timestamp; | ||
owner = msg.sender; | ||
} | ||
|
||
function fuse(address[] memory _materials, uint[] memory _amounts) public { | ||
require(_materials.length == _amounts.length ); | ||
require(_materials.length > 0, "materials > 0" ); | ||
|
||
materials = _materials; | ||
amounts = _amounts; | ||
} | ||
|
||
function mint(address to, uint256 amount) public { | ||
_mint(to, amount); | ||
} | ||
|
||
function burn(address to, uint256 amount) public { | ||
_burn(to, amount); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require("@nomiclabs/hardhat-waffle"); | ||
|
||
task("accounts", "Prints the list of accounts", async () => { | ||
const accounts = await ethers.getSigners(); | ||
|
||
for (const account of accounts) { | ||
console.log(account.address); | ||
} | ||
}); | ||
|
||
module.exports = { | ||
defaultNetwork: "localhost", | ||
networks: { | ||
localhost: { | ||
url: "http://127.0.0.1:8545" | ||
}, | ||
hardhat: {} | ||
// rinkeby: { | ||
// url: "https://rinkeby.infura.io/v3/<token>", | ||
// accounts: ["privateKey1"] | ||
// } | ||
}, | ||
solidity: { | ||
version: "0.6.12", | ||
settings: { | ||
optimizer: { | ||
enabled: true, | ||
runs: 200 | ||
} | ||
} | ||
} | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "eth-hardhat-demo", | ||
"version": "0.0.1", | ||
"description": "eth hardhat demo", | ||
"main": "index.js", | ||
"repository": "https://github.com/liushooter/eth-hardhat-demo", | ||
"author": "Rebase Team", | ||
"license": "BSD-3-Clause", | ||
"dependencies": { | ||
"@openzeppelin/contracts": "^3.2.0", | ||
"hardhat": "^2.0.3" | ||
}, | ||
"devDependencies": { | ||
"@nomiclabs/hardhat-ethers": "^2.0.0", | ||
"@nomiclabs/hardhat-waffle": "^2.0.0", | ||
"chai": "^4.2.0", | ||
"ethereum-waffle": "^3.0.0", | ||
"ethers": "^5.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
async function main() { | ||
const Token = await ethers.getContractFactory("Token"); | ||
|
||
const token = await Token.deploy("abc", "def"); | ||
|
||
console.log("Token deployed to:", token.address); | ||
} | ||
|
||
main() | ||
.then(() => process.exit(0)) | ||
.catch(error => { | ||
console.error(error); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const { expect } = require("chai"); | ||
|
||
describe("Token", function() { | ||
it("fuse", async function() { | ||
const Token = await ethers.getContractFactory("Token"); | ||
|
||
const a = "0x" + "1".repeat(40) | ||
const b = "0x" + "2".repeat(40) | ||
|
||
const _tokens = [a, b] | ||
const _amounts = [200, 130] | ||
const token = await Token.deploy("rebase", "rebase"); | ||
await token.deployed(); | ||
|
||
console.log("Token deployed to:", token.address); | ||
|
||
await token.fuse(_tokens, _amounts); | ||
|
||
const synthesis = await token.synthesis() | ||
const created = await token.created() | ||
const owner = await token.owner() | ||
|
||
const materials = await token.materials(0) | ||
const amounts = await token.amounts(0) | ||
|
||
console.log(synthesis) | ||
console.log(created.toNumber()) | ||
console.log(owner) | ||
|
||
console.log(materials) | ||
console.log(amounts.toNumber()) | ||
|
||
expect(synthesis).to.equal(true); | ||
}); | ||
}); |
Oops, something went wrong.