-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
14 changed files
with
227,092 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
.env | ||
package-lock.json |
109,777 changes: 109,777 additions & 0 deletions
109,777
Educational/hardHat/artifacts/build-info/9ebf77ed-7109-4bf7-bb02-c30b5134d3b3.json
Large diffs are not rendered by default.
Oops, something went wrong.
109,546 changes: 109,546 additions & 0 deletions
109,546
Educational/hardHat/artifacts/build-info/a211be2b-d9cf-40af-b99f-8f7db3739e3a.json
Large diffs are not rendered by default.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
Educational/hardHat/artifacts/contracts/Token.sol/Token.dbg.json
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,4 @@ | ||
{ | ||
"_format": "hh-sol-dbg-1", | ||
"buildInfo": "../../build-info/a211be2b-d9cf-40af-b99f-8f7db3739e3a.json" | ||
} |
130 changes: 130 additions & 0 deletions
130
Educational/hardHat/artifacts/contracts/Token.sol/Token.json
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,130 @@ | ||
{ | ||
"_format": "hh-sol-artifact-1", | ||
"contractName": "Token", | ||
"sourceName": "contracts/Token.sol", | ||
"abi": [ | ||
{ | ||
"inputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "constructor" | ||
}, | ||
{ | ||
"anonymous": false, | ||
"inputs": [ | ||
{ | ||
"indexed": true, | ||
"internalType": "address", | ||
"name": "from", | ||
"type": "address" | ||
}, | ||
{ | ||
"indexed": true, | ||
"internalType": "address", | ||
"name": "to", | ||
"type": "address" | ||
}, | ||
{ | ||
"indexed": false, | ||
"internalType": "uint256", | ||
"name": "amount", | ||
"type": "uint256" | ||
} | ||
], | ||
"name": "transferEvent", | ||
"type": "event" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "address", | ||
"name": "account", | ||
"type": "address" | ||
} | ||
], | ||
"name": "balanceOf", | ||
"outputs": [ | ||
{ | ||
"internalType": "uint256", | ||
"name": "", | ||
"type": "uint256" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "name", | ||
"outputs": [ | ||
{ | ||
"internalType": "string", | ||
"name": "", | ||
"type": "string" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "owner", | ||
"outputs": [ | ||
{ | ||
"internalType": "address", | ||
"name": "", | ||
"type": "address" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "symbol", | ||
"outputs": [ | ||
{ | ||
"internalType": "string", | ||
"name": "", | ||
"type": "string" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "totalSupply", | ||
"outputs": [ | ||
{ | ||
"internalType": "uint256", | ||
"name": "", | ||
"type": "uint256" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "address", | ||
"name": "to", | ||
"type": "address" | ||
}, | ||
{ | ||
"internalType": "uint256", | ||
"name": "amount", | ||
"type": "uint256" | ||
} | ||
], | ||
"name": "transfer", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
} | ||
], | ||
"bytecode": "0x60806040526040518060400160405280601081526020017f4d79204861726468617420546f6b656e000000000000000000000000000000008152506000908051906020019061004f92919061013c565b506040518060400160405280600381526020017f4d425400000000000000000000000000000000000000000000000000000000008152506001908051906020019061009b92919061013c565b50620f42406002553480156100af57600080fd5b50600254600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555033600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506101d9565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061017d57805160ff19168380011785556101ab565b828001600101855582156101ab579182015b828111156101aa57825182559160200191906001019061018f565b5b5090506101b891906101bc565b5090565b5b808211156101d55760008160009055506001016101bd565b5090565b610604806101e86000396000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c806306fdde031461006757806318160ddd146100ea57806370a08231146101085780638da5cb5b1461016057806395d89b4114610194578063a9059cbb14610217575b600080fd5b61006f610265565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100af578082015181840152602081019050610094565b50505050905090810190601f1680156100dc5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6100f2610303565b6040518082815260200191505060405180910390f35b61014a6004803603602081101561011e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610309565b6040518082815260200191505060405180910390f35b610168610352565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61019c610378565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101dc5780820151818401526020810190506101c1565b50505050905090810190601f1680156102095780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102636004803603604081101561022d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610416565b005b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102fb5780601f106102d0576101008083540402835291602001916102fb565b820191906000526020600020905b8154815290600101906020018083116102de57829003601f168201915b505050505081565b60025481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60018054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561040e5780601f106103e35761010080835404028352916020019161040e565b820191906000526020600020905b8154815290600101906020018083116103f157829003601f168201915b505050505081565b80600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410156104cb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260118152602001807f4e6f7420656e6f75676820746f6b656e7300000000000000000000000000000081525060200191505060405180910390fd5b80600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555080600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f5d439cf3a1f6215b41908e5b0b300f39679a3ff1cc010691c1d4ec4d0e2a4ebb836040518082815260200191505060405180910390a3505056fea264697066735822122037db481bf5bce07a3be02b4e6522afd61337327788974db0b63efafe4df8e43564736f6c63430007030033", | ||
"deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100625760003560e01c806306fdde031461006757806318160ddd146100ea57806370a08231146101085780638da5cb5b1461016057806395d89b4114610194578063a9059cbb14610217575b600080fd5b61006f610265565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100af578082015181840152602081019050610094565b50505050905090810190601f1680156100dc5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6100f2610303565b6040518082815260200191505060405180910390f35b61014a6004803603602081101561011e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610309565b6040518082815260200191505060405180910390f35b610168610352565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61019c610378565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101dc5780820151818401526020810190506101c1565b50505050905090810190601f1680156102095780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102636004803603604081101561022d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610416565b005b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102fb5780601f106102d0576101008083540402835291602001916102fb565b820191906000526020600020905b8154815290600101906020018083116102de57829003601f168201915b505050505081565b60025481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60018054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561040e5780601f106103e35761010080835404028352916020019161040e565b820191906000526020600020905b8154815290600101906020018083116103f157829003601f168201915b505050505081565b80600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410156104cb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260118152602001807f4e6f7420656e6f75676820746f6b656e7300000000000000000000000000000081525060200191505060405180910390fd5b80600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555080600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f5d439cf3a1f6215b41908e5b0b300f39679a3ff1cc010691c1d4ec4d0e2a4ebb836040518082815260200191505060405180910390a3505056fea264697066735822122037db481bf5bce07a3be02b4e6522afd61337327788974db0b63efafe4df8e43564736f6c63430007030033", | ||
"linkReferences": {}, | ||
"deployedLinkReferences": {} | ||
} |
4 changes: 4 additions & 0 deletions
4
Educational/hardHat/artifacts/hardhat/console.sol/console.dbg.json
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,4 @@ | ||
{ | ||
"_format": "hh-sol-dbg-1", | ||
"buildInfo": "../../build-info/9ebf77ed-7109-4bf7-bb02-c30b5134d3b3.json" | ||
} |
10 changes: 10 additions & 0 deletions
10
Educational/hardHat/artifacts/hardhat/console.sol/console.json
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,10 @@ | ||
{ | ||
"_format": "hh-sol-artifact-1", | ||
"contractName": "console", | ||
"sourceName": "hardhat/console.sol", | ||
"abi": [], | ||
"bytecode": "0x60566023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122099b443ac06edd1c29f7b1cb016373e00c8a0b490098b2633c81b92c0a302a53364736f6c63430007030033", | ||
"deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122099b443ac06edd1c29f7b1cb016373e00c8a0b490098b2633c81b92c0a302a53364736f6c63430007030033", | ||
"linkReferences": {}, | ||
"deployedLinkReferences": {} | ||
} |
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,75 @@ | ||
{ | ||
"_format": "hh-sol-cache-2", | ||
"files": { | ||
"/Users/veronicac/Desktop/projects/Ethereum/Educational/hardHat/contracts/Token.sol": { | ||
"lastModificationDate": 1606909407584, | ||
"contentHash": "601adc5e50fbddbd0b33f4ae25b9be6c", | ||
"sourceName": "contracts/Token.sol", | ||
"solcConfig": { | ||
"version": "0.7.3", | ||
"settings": { | ||
"optimizer": { | ||
"enabled": false, | ||
"runs": 200 | ||
}, | ||
"outputSelection": { | ||
"*": { | ||
"*": [ | ||
"abi", | ||
"evm.bytecode", | ||
"evm.deployedBytecode", | ||
"evm.methodIdentifiers" | ||
], | ||
"": [ | ||
"ast" | ||
] | ||
} | ||
} | ||
} | ||
}, | ||
"imports": [ | ||
"hardhat/console.sol" | ||
], | ||
"versionPragmas": [ | ||
"^0.7.0" | ||
], | ||
"artifacts": [ | ||
"Token" | ||
] | ||
}, | ||
"/Users/veronicac/Desktop/projects/Ethereum/Educational/hardHat/node_modules/hardhat/console.sol": { | ||
"lastModificationDate": 1606902247272, | ||
"contentHash": "c20b2460755f312099ccd61427237ded", | ||
"sourceName": "hardhat/console.sol", | ||
"solcConfig": { | ||
"version": "0.7.3", | ||
"settings": { | ||
"optimizer": { | ||
"enabled": false, | ||
"runs": 200 | ||
}, | ||
"outputSelection": { | ||
"*": { | ||
"*": [ | ||
"abi", | ||
"evm.bytecode", | ||
"evm.deployedBytecode", | ||
"evm.methodIdentifiers" | ||
], | ||
"": [ | ||
"ast" | ||
] | ||
} | ||
} | ||
} | ||
}, | ||
"imports": [], | ||
"versionPragmas": [ | ||
">=0.4.22 <0.8.0" | ||
], | ||
"artifacts": [ | ||
"console" | ||
] | ||
} | ||
} | ||
} |
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,79 @@ | ||
// Solidity files have to start with this pragma. | ||
// It will be used by the Solidity compiler to validate its version. | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.7.0; | ||
|
||
// Import the console log to be able to log variables within a call | ||
import "hardhat/console.sol"; | ||
|
||
// This is the main building block for smart contracts. | ||
contract Token { | ||
// Some string type variables to identify the token. | ||
// The `public` modifier makes a variable readable from outside the contract. | ||
string public name = "My Hardhat Token"; | ||
string public symbol = "MBT"; | ||
|
||
// The fixed amount of tokens stored in an unsigned integer type variable. | ||
uint256 public totalSupply = 1000000; | ||
|
||
// An address type variable is used to store ethereum accounts. | ||
address public owner; | ||
|
||
// A mapping is a key/value map. Here we store each account balance. | ||
mapping(address => uint256) balances; | ||
|
||
// An event | ||
event transferEvent(address indexed from, address indexed to, uint256 amount); | ||
|
||
/** | ||
* Contract initialization. | ||
* | ||
* The `constructor` is executed only once when the contract is created. | ||
*/ | ||
constructor() { | ||
// The totalSupply is assigned to transaction sender, which is the account | ||
// that is deploying the contract. | ||
balances[msg.sender] = totalSupply; | ||
owner = msg.sender; | ||
} | ||
|
||
/** | ||
* A function to transfer tokens. | ||
* | ||
* The `external` modifier makes a function *only* callable from outside | ||
* the contract. | ||
*/ | ||
function transfer(address to, uint256 amount) external { | ||
// Check if the transaction sender has enough tokens. | ||
// If `require`'s first argument evaluates to `false` then the | ||
// transaction will revert. | ||
require(balances[msg.sender] >= amount, "Not enough tokens"); | ||
|
||
// Transfer the amount. | ||
balances[msg.sender] -= amount; | ||
balances[to] += amount; | ||
|
||
/** | ||
Uncomment to be able to console.log() variables from within solidity | ||
smart contracts | ||
*/ | ||
// console.log("Sender balance is %s tokens", balances[msg.sender]); | ||
// console.log("Trying to send %s tokens to %s", amount, to); | ||
|
||
emit transferEvent( | ||
msg.sender, | ||
to, | ||
amount | ||
); | ||
} | ||
|
||
/** | ||
* Read only function to retrieve the token balance of a given account. | ||
* | ||
* The `view` modifier indicates that it doesn't modify the contract's | ||
* state, which allows us to call it without executing a transaction. | ||
*/ | ||
function balanceOf(address account) external view returns (uint256) { | ||
return balances[account]; | ||
} | ||
} |
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,29 @@ | ||
require("@nomiclabs/hardhat-waffle"); | ||
// env reader | ||
require("dotenv").config(); | ||
|
||
/** | ||
* API key for using Infura. To generate keys go to https://infura.io/ | ||
* @notice Never hard code API keys within a file that is tracked by git. | ||
* This file is tracked by git, as such we pull the API keys from | ||
* the `.env` file. | ||
*/ | ||
const INFURA_PROJECT_ID = process.env.INFURA_PROJECT_ID; | ||
|
||
/** | ||
* Private key of deployer | ||
* @notice Never hard code private keys within a file that is tracked by git. | ||
* This file is tracked by git, as such we pull the private keys from | ||
* the `.env` file. | ||
*/ | ||
const ROPSTEN_PRIVATE_KEY = process.env.ROPSTEN_PRIVATE_KEY; | ||
|
||
module.exports = { | ||
solidity: "0.7.3", | ||
networks: { | ||
ropsten: { | ||
url: `https://ropsten.infura.io/v3/${INFURA_PROJECT_ID}`, | ||
accounts: [`0x${ROPSTEN_PRIVATE_KEY}`] | ||
} | ||
} | ||
}; |
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,25 @@ | ||
{ | ||
"name": "hardHat", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"author": "@nicca42", | ||
"license": "MIT", | ||
"private": false, | ||
"dependencies": { | ||
"dotenv": "^8.2.0", | ||
"hardhat": "^2.0.4" | ||
}, | ||
"devDependencies": { | ||
"@nomiclabs/hardhat-ethers": "^2.0.1", | ||
"@nomiclabs/hardhat-waffle": "^2.0.1", | ||
"chai": "^4.2.0", | ||
"ethereum-waffle": "^3.2.1", | ||
"ethers": "^5.0.23" | ||
}, | ||
"scripts": { | ||
"compile": "hardhat compile", | ||
"test": "hardhat test", | ||
"deploy:local": "hardhat run scripts/deploy.js", | ||
"deploy:ropsten": "npx hardhat run scripts/deploy.js --network ropsten" | ||
} | ||
} |
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,27 @@ | ||
// The deployment script | ||
const main = async (network) => { | ||
// Getting the first signer as the deployer | ||
const [deployer] = await ethers.getSigners(); | ||
// Saving the info to be logged in the table (deployer address) | ||
var deployerLog = { Label: "Deploying Address", Info: deployer.address }; | ||
// Saving the info to be logged in the table (deployer address) | ||
var deployerBalanceLog = { | ||
Label: "Deployer ETH Balance", | ||
Info: (await deployer.getBalance()).toString() | ||
}; | ||
// Gets the abi, bytecode & name of the contract | ||
const Token = await ethers.getContractFactory("Token"); | ||
// Deploys the token | ||
const token = await Token.deploy(); | ||
// Saving the info to be logged in the table (deployer address) | ||
var tokenLog = { Label: "Deployed Token Address", Info: token.address }; | ||
|
||
console.table([deployerLog, deployerBalanceLog, tokenLog]); | ||
} | ||
// Runs the deployment script, catching any errors | ||
main() | ||
.then(() => process.exit(0)) | ||
.catch((error) => { | ||
console.error(error); | ||
process.exit(1); | ||
}); |
Oops, something went wrong.