-
Notifications
You must be signed in to change notification settings - Fork 29
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
23 changed files
with
7,015 additions
and
63 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
6,519 changes: 6,519 additions & 0 deletions
6,519
.github/actions/geth/truffle/build/contracts/USDC.json
Large diffs are not rendered by default.
Oops, something went wrong.
Empty file.
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,60 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity ^0.8.17; | ||
|
||
contract USDC { | ||
|
||
event Transfer(address indexed from, address indexed to, uint tokens); | ||
event Approval(address indexed tokenOwner, address indexed spender, uint tokens); | ||
|
||
string public constant name = "USDC"; | ||
string public constant symbol = "USDC"; | ||
uint8 public constant decimals = 6; | ||
|
||
mapping(address => uint256) balances; | ||
|
||
mapping(address => mapping (address => uint256)) allowed; | ||
|
||
uint256 totalSupply_; | ||
|
||
constructor() { | ||
totalSupply_ = 888888888888888; | ||
balances[msg.sender] = totalSupply_; | ||
} | ||
|
||
function totalSupply() public view returns (uint256) { | ||
return totalSupply_; | ||
} | ||
|
||
function balanceOf(address tokenOwner) public view returns (uint) { | ||
return balances[tokenOwner]; | ||
} | ||
|
||
function transfer(address receiver, uint numTokens) public returns (bool) { | ||
require(numTokens <= balances[msg.sender]); | ||
balances[msg.sender] -= numTokens; | ||
balances[receiver] += numTokens; | ||
emit Transfer(msg.sender, receiver, numTokens); | ||
return true; | ||
} | ||
|
||
function approve(address delegate, uint numTokens) public returns (bool) { | ||
allowed[msg.sender][delegate] = numTokens; | ||
emit Approval(msg.sender, delegate, numTokens); | ||
return true; | ||
} | ||
|
||
function allowance(address owner, address delegate) public view returns (uint) { | ||
return allowed[owner][delegate]; | ||
} | ||
|
||
function transferFrom(address owner, address buyer, uint numTokens) public returns (bool) { | ||
require(numTokens <= balances[owner]); | ||
require(numTokens <= allowed[owner][msg.sender]); | ||
|
||
balances[owner] -= numTokens; | ||
allowed[owner][msg.sender] -= numTokens; | ||
balances[buyer] += numTokens; | ||
emit Transfer(owner, buyer, numTokens); | ||
return true; | ||
} | ||
} |
Empty file.
4 changes: 4 additions & 0 deletions
4
.github/actions/geth/truffle/migrations/2_deploy_contracts.js
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 @@ | ||
var USDC = artifacts.require("./USDC.sol"); | ||
module.exports = function(deployer) { | ||
deployer.deploy(USDC); | ||
}; |
Empty file.
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,158 @@ | ||
/** | ||
* 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: | ||
* | ||
* https://trufflesuite.com/docs/truffle/reference/configuration | ||
* | ||
* Hands-off deployment with Infura | ||
* -------------------------------- | ||
* | ||
* Do you have a complex application that requires lots of transactions to deploy? | ||
* Use this approach to make deployment a breeze 🏖️: | ||
* | ||
* Infura deployment needs a wallet provider (like @truffle/hdwallet-provider) | ||
* to sign transactions before they're sent to a remote public node. | ||
* Infura accounts are available for free at 🔍: https://infura.io/register | ||
* | ||
* You'll need a mnemonic - the twelve word phrase the wallet uses to generate | ||
* public/private key pairs. You can store your secrets 🤐 in a .env file. | ||
* In your project root, run `$ npm install dotenv`. | ||
* Create .env (which should be .gitignored) and declare your MNEMONIC | ||
* and Infura PROJECT_ID variables inside. | ||
* For example, your .env file will have the following structure: | ||
* | ||
* MNEMONIC = <Your 12 phrase mnemonic> | ||
* PROJECT_ID = <Your Infura project id> | ||
* | ||
* Deployment with Truffle Dashboard (Recommended for best security practice) | ||
* -------------------------------------------------------------------------- | ||
* | ||
* Are you concerned about security and minimizing rekt status 🤔? | ||
* Use this method for best security: | ||
* | ||
* Truffle Dashboard lets you review transactions in detail, and leverages | ||
* MetaMask for signing, so there's no need to copy-paste your mnemonic. | ||
* More details can be found at 🔎: | ||
* | ||
* https://trufflesuite.com/docs/truffle/getting-started/using-the-truffle-dashboard/ | ||
*/ | ||
|
||
// require('dotenv').config(); | ||
// const { MNEMONIC, PROJECT_ID } = process.env; | ||
|
||
// const HDWalletProvider = require('@truffle/hdwallet-provider'); | ||
|
||
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 managed Ganache instance 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> | ||
*/ | ||
// rpc: { | ||
// host:"localhost", | ||
// port:8546 | ||
// }, | ||
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, 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. | ||
// | ||
|
||
|
||
// networks: { | ||
// development: { | ||
// host: "localhost", //our network is running on localhost | ||
// port: 8546, // port where your blockchain is running | ||
// network_id: "*", | ||
// from: "0x4cdBd835fE18BD93ccA39A262Cff72dbAC99E24F", // use the account-id generated during the setup process | ||
// gas: 20000000 | ||
// } | ||
// } | ||
development: { | ||
host: "127.0.0.1", // Localhost (default: none) | ||
port: 8546, // Standard Ethereum port (default: none) | ||
network_id: 1, // Any network (default: none) | ||
gas: 7000000, // Gas sent with each transaction (default: ~6700000) | ||
gasPrice: 20000000000, // 20 gwei (in wei) (default: 100 gwei) | ||
from: "0x4cdBd835fE18BD93ccA39A262Cff72dbAC99E24F", // Account to send transactions from (default: accounts[0]) | ||
}, | ||
// | ||
// An additional network, but with some advanced options… | ||
// advanced: { | ||
// port: 8777, // Custom port | ||
// network_id: 1342, // Custom network | ||
// gas: 20000000, // Gas sent with each transaction (default: ~6700000) | ||
// gasPrice: 20000000000, // 20 gwei (in wei) (default: 100 gwei) | ||
// from: "0x4cdBd835fE18BD93ccA39A262Cff72dbAC99E24F", // Account to send transactions from (default: accounts[0]) | ||
// websocket: true // Enable EventEmitter interface for web3 (default: false) | ||
// } | ||
// | ||
// Useful for deploying to a public network. | ||
// Note: It's important to wrap the provider as a function to ensure truffle uses a new provider every time. | ||
// goerli: { | ||
// provider: () => new HDWalletProvider(MNEMONIC, `https://goerli.infura.io/v3/${PROJECT_ID}`), | ||
// network_id: 5, // Goerli's id | ||
// confirmations: 2, // # of confirmations 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.17" // 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. The default storage location can also be | ||
// overridden by specifying the adapter settings, as shown in the commented code below. | ||
// | ||
// NOTE: It is not possible to migrate your contracts to truffle DB and you should | ||
// make a backup of your artifacts to a safe location before enabling this feature. | ||
// | ||
// After you backed up your artifacts you can utilize db by running migrate as follows: | ||
// $ truffle migrate --reset --compile-all | ||
// | ||
// db: { | ||
// enabled: false, | ||
// host: "127.0.0.1", | ||
// adapter: { | ||
// name: "indexeddb", | ||
// settings: { | ||
// directory: ".db" | ||
// } | ||
// } | ||
// } | ||
}; |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#!/bin/bash | ||
|
||
# downloading cli | ||
curl -sSfL https://raw.githubusercontent.com/coinbase/rosetta-cli/master/scripts/install.sh | sh -s | ||
curl -sSfL https://raw.githubusercontent.com/coinbase/rosetta-cli/master/scripts/install.sh | sh -s v0.10.0 | ||
|
||
echo "start check:construction" | ||
./bin/rosetta-cli --configuration-file examples/ethereum/rosetta-cli-conf/devnet/config.json check:construction |
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,21 @@ | ||
from web3 import Web3 | ||
from web3.middleware import geth_poa_middleware | ||
|
||
|
||
web3 = Web3(Web3.HTTPProvider("http://127.0.0.1:8546")) | ||
web3.middleware_onion.inject(geth_poa_middleware, layer=0) | ||
|
||
print("latest block", web3.eth.block_number) | ||
|
||
abi= [{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":"false","inputs":[{"indexed":"true","internalType":"address","name":"tokenOwner","type":"address"},{"indexed":"true","internalType":"address","name":"spender","type":"address"},{"indexed":"false","internalType":"uint256","name":"tokens","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":"false","inputs":[{"indexed":"true","internalType":"address","name":"from","type":"address"},{"indexed":"true","internalType":"address","name":"to","type":"address"},{"indexed":"false","internalType":"uint256","name":"tokens","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"delegate","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"delegate","type":"address"},{"internalType":"uint256","name":"numTokens","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenOwner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"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":"receiver","type":"address"},{"internalType":"uint256","name":"numTokens","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"buyer","type":"address"},{"internalType":"uint256","name":"numTokens","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}] | ||
address = '0x62F3712A8A2bF3482F9Aa42F2C8296CF50774DDD' | ||
contract= web3.eth.contract(address=address, abi=abi) | ||
|
||
seedAddress="0x4cdBd835fE18BD93ccA39A262Cff72dbAC99E24F" | ||
targetAddress="0x622Fbe99b3A378FAC736bf29d7e23B85E18816eB" | ||
|
||
print("symbol is ", contract.functions.symbol().call()) | ||
print("decimal is ", contract.functions.decimals().call()) | ||
print("address is ", contract.address) | ||
print("seedAddress balance is ", contract.functions.balanceOf(seedAddress).call()) | ||
print("targetAddress balance is ", contract.functions.balanceOf(targetAddress).call()) |
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 @@ | ||
#!/bin/bash | ||
|
||
echo "update apt-get" | ||
apt-get update | ||
|
||
echo "install nodejs" | ||
apt-get install -y nodejs | ||
|
||
echo "check npm version" | ||
npm -v | ||
|
||
echo "install truffle" | ||
npm install -g truffle | ||
|
||
echo "install solc" | ||
npm install -g solc | ||
|
||
cd .github/actions/geth/truffle | ||
echo "deploy the contract" | ||
truffle migrate |
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
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
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
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
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
Oops, something went wrong.