Initial commit
This commit is contained in:
commit
5d78e05703
|
@ -0,0 +1,6 @@
|
||||||
|
secrets.json
|
||||||
|
build/
|
||||||
|
cache/
|
||||||
|
node_modules/
|
||||||
|
.idea/
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) [2021] [Shaun Reed]
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
|
@ -0,0 +1,7 @@
|
||||||
|
# KARMA
|
||||||
|
|
||||||
|
![Karmatoken](karmatoken.jpg)
|
||||||
|
|
||||||
|
An Ethereum ERC20 token minted by my cat, Karma.
|
||||||
|
|
||||||
|
[Ropsten ERC20 Token](https://ropsten.etherscan.io/token/0x6f502849750960cdb3c225bedab6a05065f85855)
|
|
@ -0,0 +1,19 @@
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
pragma solidity >=0.4.22 <0.9.0;
|
||||||
|
|
||||||
|
contract Migrations {
|
||||||
|
address public owner = msg.sender;
|
||||||
|
uint public last_completed_migration;
|
||||||
|
|
||||||
|
modifier restricted() {
|
||||||
|
require(
|
||||||
|
msg.sender == owner,
|
||||||
|
"This function is restricted to the contract's owner"
|
||||||
|
);
|
||||||
|
_;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setCompleted(uint completed) public restricted {
|
||||||
|
last_completed_migration = completed;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,110 @@
|
||||||
|
// Copyright [2021] - [2021], [Shaun Reed] and [Karma] contributors
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
pragma solidity >= 0.8.0;
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// Import ERC Token Standard #20 Interface
|
||||||
|
// ETH EIP repo: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// SourceCoin Contract
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
contract Karma is IERC20
|
||||||
|
{
|
||||||
|
string public name;
|
||||||
|
string public symbol;
|
||||||
|
uint8 public decimals; // 18 decimals is the strongly suggested default, avoid changing it
|
||||||
|
uint256 public _totalSupply;
|
||||||
|
|
||||||
|
// Balances for each account; A hashmap using wallet address as key and uint as value
|
||||||
|
mapping(address => uint) balances;
|
||||||
|
|
||||||
|
// Owner of account approves the transfer of an amount to another account
|
||||||
|
mapping(address => mapping(address => uint)) allowed;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constrctor function
|
||||||
|
*
|
||||||
|
* Initializes contract with initial supply tokens to the creator of the contract
|
||||||
|
*/
|
||||||
|
constructor()
|
||||||
|
{
|
||||||
|
name = "Karma"; // Name of the token
|
||||||
|
symbol = "KRMA"; // Abbreviation of the token
|
||||||
|
decimals = 18; // Number of decimals that can be used to split token
|
||||||
|
|
||||||
|
|
||||||
|
// FORMAT: <SUPPLY><DECIMALS>
|
||||||
|
// Where SUPPLY is the number of coins in base 10 decimal notation
|
||||||
|
// And DECIMALS is a trailing number of 0's; Count must match `decimals` value set above
|
||||||
|
// 1000 000 000 000000000000000000 == 1 billion total supply;
|
||||||
|
// + trailing 0's represent the 18 decimal locations that can be used to send fractions
|
||||||
|
_totalSupply = 1000000000000000000000000000;
|
||||||
|
|
||||||
|
|
||||||
|
// Set the remaining balance of the contract owner to the total supply
|
||||||
|
balances[msg.sender] = _totalSupply; // msg.sender is the calling address for this constructor
|
||||||
|
// Transfer the total supply to the contract owner on initialization
|
||||||
|
emit Transfer(address(0), msg.sender, _totalSupply); // address(0) is used to represent a new TX
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Get the total circulating supply of the token
|
||||||
|
function totalSupply() public override view returns (uint)
|
||||||
|
{
|
||||||
|
// By subtracting from tokens held at address(0), we provide an address to 'burn' the supply
|
||||||
|
return _totalSupply - balances[address(0)]; // Subtract from tokens held at address(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the token balance for account `tokenOwner`
|
||||||
|
function balanceOf(address tokenOwner) public override view returns (uint balance)
|
||||||
|
{
|
||||||
|
return balances[tokenOwner]; // Return the balance of the owner's address
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @param tokenOwner The address of the account owning tokens
|
||||||
|
/// @param spender The address of the account able to transfer the tokens
|
||||||
|
/// returns Amount of remaining tokens allowed to spent
|
||||||
|
function allowance(address tokenOwner, address spender) public override view returns (uint remaining)
|
||||||
|
{
|
||||||
|
return allowed[tokenOwner][spender];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow `spender` to withdraw from your account, multiple times, up to the `tokens`
|
||||||
|
// If this function is called again it overwrites the current allowance with _value.
|
||||||
|
function approve(address spender, uint tokens) public override returns (bool success)
|
||||||
|
{
|
||||||
|
allowed[msg.sender][spender] = tokens;
|
||||||
|
emit Approval(msg.sender, spender, tokens);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transfer the balance from owner's account to another account
|
||||||
|
function transfer(address to, uint tokens) public override returns (bool success)
|
||||||
|
{
|
||||||
|
balances[msg.sender] = balances[msg.sender] - tokens;
|
||||||
|
balances[to] = balances[to] + tokens;
|
||||||
|
emit Transfer(msg.sender, to, tokens);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send `tokens` amount of tokens from address `from` to address `to`
|
||||||
|
// The transferFrom method is used for a withdraw workflow, allowing contracts to send
|
||||||
|
// tokens on your behalf, for example to "deposit" to a contract address and/or to charge
|
||||||
|
// fees in sub-currencies; the command should fail unless the _from account has
|
||||||
|
// deliberately authorized the sender of the message via some mechanism; we propose
|
||||||
|
// these standardized APIs for approval:
|
||||||
|
function transferFrom(address from, address to, uint tokens) public override returns (bool success)
|
||||||
|
{
|
||||||
|
balances[from] = balances[from] - tokens;
|
||||||
|
allowed[from][msg.sender] = allowed[from][msg.sender] - tokens;
|
||||||
|
balances[to] = balances[to] - tokens;
|
||||||
|
emit Transfer(from, to, tokens);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"alchemyApiUrl": "https://eth-ropsten.alchemyapi.io/v2/YOUR_ALCHEMY_API_KEY",
|
||||||
|
"mnemonic": "word word word word word word word word word word word"
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 193 KiB |
|
@ -0,0 +1,5 @@
|
||||||
|
const Migrations = artifacts.require("Migrations");
|
||||||
|
|
||||||
|
module.exports = function (deployer) {
|
||||||
|
deployer.deploy(Migrations);
|
||||||
|
};
|
|
@ -0,0 +1,5 @@
|
||||||
|
const Karma = artifacts.require("Karma");
|
||||||
|
|
||||||
|
module.exports = function (deployer) {
|
||||||
|
deployer.deploy(Karma);
|
||||||
|
};
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"name": "karma",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "![Karmatoken](karmatoken.jpg)",
|
||||||
|
"main": "truffle-config.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "Shaun Reed",
|
||||||
|
"license": "MIT",
|
||||||
|
"devDependencies": {
|
||||||
|
"@openzeppelin/contracts": "^4.0.0",
|
||||||
|
"@truffle/hdwallet-provider": "^1.3.0",
|
||||||
|
"truffle": "^5.3.3"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,114 @@
|
||||||
|
/**
|
||||||
|
* Use this file to configure your truffle project. It's seeded with some
|
||||||
|
* common settings for different networks and features like migrations,
|
||||||
|
* compilation and testing. Uncomment the ones you need or modify
|
||||||
|
* them to suit your project as necessary.
|
||||||
|
*
|
||||||
|
* More information about configuration can be found at:
|
||||||
|
*
|
||||||
|
* trufflesuite.com/docs/advanced/configuration
|
||||||
|
*
|
||||||
|
* To deploy via Infura you'll need a wallet provider (like @truffle/hdwallet-provider)
|
||||||
|
* to sign your transactions before they're sent to a remote public node. Infura accounts
|
||||||
|
* are available for free at: infura.io/register.
|
||||||
|
*
|
||||||
|
* You'll also need a mnemonic - the twelve word phrase the wallet uses to generate
|
||||||
|
* public/private key pairs. If you're publishing your code to GitHub make sure you load this
|
||||||
|
* phrase from a file you've .gitignored so it doesn't accidentally become public.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
const HDWalletProvider = require('@truffle/hdwallet-provider');
|
||||||
|
const { alchemyApiUrl, mnemonic } = require('./secrets.json');
|
||||||
|
// const infuraKey = "fj4jll3k.....";
|
||||||
|
//
|
||||||
|
// const fs = require('fs');
|
||||||
|
// const mnemonic = fs.readFileSync(".secret").toString().trim();
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
/**
|
||||||
|
* Networks define how you connect to your ethereum client and let you set the
|
||||||
|
* defaults web3 uses to send transactions. If you don't specify one truffle
|
||||||
|
* will spin up a development blockchain for you on port 9545 when you
|
||||||
|
* run `develop` or `test`. You can ask a truffle command to use a specific
|
||||||
|
* network from the command line, e.g
|
||||||
|
*
|
||||||
|
* $ truffle test --network <network-name>
|
||||||
|
*/
|
||||||
|
|
||||||
|
networks: {
|
||||||
|
// Useful for testing. The `development` name is special - truffle uses it by default
|
||||||
|
// if it's defined here and no other network is specified at the command line.
|
||||||
|
// You should run a client (like ganache-cli, geth or parity) in a separate terminal
|
||||||
|
// tab if you use this network and you must also set the `host`, `port` and `network_id`
|
||||||
|
// options below to some value.
|
||||||
|
//
|
||||||
|
// development: {
|
||||||
|
// host: "127.0.0.1", // Localhost (default: none)
|
||||||
|
// port: 8545, // Standard Ethereum port (default: none)
|
||||||
|
// network_id: "*", // Any network (default: none)
|
||||||
|
// },
|
||||||
|
// Another network with more advanced options...
|
||||||
|
// advanced: {
|
||||||
|
// port: 8777, // Custom port
|
||||||
|
// network_id: 1342, // Custom network
|
||||||
|
// gas: 8500000, // Gas sent with each transaction (default: ~6700000)
|
||||||
|
// gasPrice: 20000000000, // 20 gwei (in wei) (default: 100 gwei)
|
||||||
|
// from: <address>, // Account to send txs from (default: accounts[0])
|
||||||
|
// websocket: true // Enable EventEmitter interface for web3 (default: false)
|
||||||
|
// },
|
||||||
|
// Useful for deploying to a public network.
|
||||||
|
// NB: It's important to wrap the provider as a function.
|
||||||
|
ropsten: {
|
||||||
|
provider: () => new HDWalletProvider({
|
||||||
|
mnemonic: {
|
||||||
|
phrase: mnemonic
|
||||||
|
},
|
||||||
|
providerOrUrl: alchemyApiUrl,
|
||||||
|
chainId: 3
|
||||||
|
}),
|
||||||
|
// provider: () => new HDWalletProvider('turtle erupt shop aisle north segment clarify soda excuse help love snake', `https://eth-ropsten.alchemyapi.io/v2/msUAyuwMjIDj72x461sgdmXLxPcVm4eP`),
|
||||||
|
network_id: 3, // Ropsten's id
|
||||||
|
gas: 5500000, // Ropsten has a lower block limit than mainnet
|
||||||
|
confirmations: 2, // # of confs to wait between deployments. (default: 0)
|
||||||
|
timeoutBlocks: 200, // # of blocks before a deployment times out (minimum/default: 50)
|
||||||
|
skipDryRun: true // Skip dry run before migrations? (default: false for public nets )
|
||||||
|
},
|
||||||
|
// Useful for private networks
|
||||||
|
// private: {
|
||||||
|
// provider: () => new HDWalletProvider(mnemonic, `https://network.io`),
|
||||||
|
// network_id: 2111, // This network is yours, in the cloud.
|
||||||
|
// production: true // Treats this network as if it was a public net. (default: false)
|
||||||
|
// }
|
||||||
|
},
|
||||||
|
|
||||||
|
// Set default mocha options here, use special reporters etc.
|
||||||
|
mocha: {
|
||||||
|
// timeout: 100000
|
||||||
|
},
|
||||||
|
|
||||||
|
// Configure your compilers
|
||||||
|
compilers: {
|
||||||
|
solc: {
|
||||||
|
version: "0.8.0", // Fetch exact version from solc-bin (default: truffle's version)
|
||||||
|
// docker: true, // Use "0.5.1" you've installed locally with docker (default: false)
|
||||||
|
// settings: { // See the solidity docs for advice about optimization and evmVersion
|
||||||
|
// optimizer: {
|
||||||
|
// enabled: false,
|
||||||
|
// runs: 200
|
||||||
|
// },
|
||||||
|
// evmVersion: "byzantium"
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// Truffle DB is currently disabled by default; to enable it, change enabled: false to enabled: true
|
||||||
|
//
|
||||||
|
// Note: if you migrated your contracts prior to enabling this field in your Truffle project and want
|
||||||
|
// those previously migrated contracts available in the .db directory, you will need to run the following:
|
||||||
|
// $ truffle migrate --reset --compile-all
|
||||||
|
|
||||||
|
db: {
|
||||||
|
enabled: false
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue