Skip to content

Commit

Permalink
Connect to Web3 via Infura. Get contract details and cache.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmcd committed May 23, 2020
1 parent ffd1666 commit 5f11a3d
Show file tree
Hide file tree
Showing 23 changed files with 117 additions and 1 deletion.
46 changes: 45 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,48 @@ each block if there are not removed transactions, and prints any removed transac
0xc4dc057c1fa6742128befb189d82ef727b0555fd3066f974e23864c3c4f09416: 74
0xf65a34ff8c131c3508f52a432b45e7a5d2c34bf2a4d8996c4e18d55d045a47dc: 36
0x16a18d1351190a69f7df34b7b5336deb3e257b9fb7b4b347b2e7962911aa6215: 15
0xb88fba7fba0b343335e2c1f5816e741a07631b86909ac106db91e45d4bbbfc59: 15
0xb88fba7fba0b343335e2c1f5816e741a07631b86909ac106db91e45d4bbbfc59: 15

# Interesting contracts

## Tokens

Use [EthPlorer API](https://github.com/EverexIO/Ethplorer/wiki/Ethplorer-API) to retrieve list of top traded tokens as json

curl https://api.ethplorer.io/getTopTokens?apiKey=freekey -o cache/ethplorer_top20200523.json
## dYdX DEX
[Contract Addresses](https://docs.dydx.exchange/#/contracts)

from infmon.eth import read_credentials, connect, get_contract
read_credentials('/home/mattmcd/.mattmcd') # Populates environment variables
w3 = connect() # Connects to mainnet via Infura and sets defaultAccount

# Populate cache if needed - commented out
# c = get_contract('dYdX_SoloMargin', '0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e')

# Connect to contract
solo = w3.eth.contract(**get_contract('dYdX_SoloMargin'))

solo.all_functions()
Out[7]:
[<Function ownerSetSpreadPremium(uint256,tuple)>,
<Function getIsGlobalOperator(address)>,
<Function getMarketTokenAddress(uint256)>,
...
<Function getAdjustedAccountValues(tuple)>,
<Function getMarketMarginPremium(uint256)>,
<Function getMarketInterestRate(uint256)>]

me = w3.eth.defaultAccount

solo.functions.getMarket(0).call({'from': me.address})
Out[10]:
('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
(17223105496066458626271, 101489418110876542971309),
(1010406097301649461, 1001404702877850791, 1590241097),
'0xf61AE328463CD997C7b58e7045CdC613e1cFdb69',
'0x7538651D874b7578CF52152c9ABD8f6617a38403',
(0,),
(0,),
False)
1 change: 1 addition & 0 deletions cache/ALC.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"address": "0xa3f440ef604a6380a030360f85bb0dedb6db5a85", "abi": [{"constant": false, "inputs": [{"name": "_userPoolAddress", "type": "address"}, {"name": "_platformPoolAddress", "type": "address"}, {"name": "_smPoolAddress", "type": "address"}], "name": "setUserPoolAddress", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function"}, {"constant": true, "inputs": [], "name": "name", "outputs": [{"name": "", "type": "string"}], "payable": false, "stateMutability": "view", "type": "function"}, {"constant": false, "inputs": [{"name": "_spender", "type": "address"}, {"name": "_value", "type": "uint256"}], "name": "approve", "outputs": [{"name": "success", "type": "bool"}], "payable": false, "stateMutability": "nonpayable", "type": "function"}, {"constant": true, "inputs": [], "name": "totalSupply", "outputs": [{"name": "", "type": "uint256"}], "payable": false, "stateMutability": "view", "type": "function"}, {"constant": true, "inputs": [], "name": "userPool", "outputs": [{"name": "", "type": "address"}], "payable": false, "stateMutability": "view", "type": "function"}, {"constant": false, "inputs": [{"name": "_from", "type": "address"}, {"name": "_to", "type": "address"}, {"name": "_value", "type": "uint256"}], "name": "transferFrom", "outputs": [{"name": "", "type": "bool"}], "payable": false, "stateMutability": "nonpayable", "type": "function"}, {"constant": false, "inputs": [{"name": "_to", "type": "address"}, {"name": "_value", "type": "uint256"}], "name": "transferTo", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function"}, {"constant": true, "inputs": [], "name": "decimals", "outputs": [{"name": "", "type": "uint8"}], "payable": false, "stateMutability": "view", "type": "function"}, {"constant": true, "inputs": [], "name": "platformPool", "outputs": [{"name": "", "type": "address"}], "payable": false, "stateMutability": "view", "type": "function"}, {"constant": false, "inputs": [{"name": "_tos", "type": "address[]"}], "name": "transferETH", "outputs": [{"name": "", "type": "bool"}], "payable": false, "stateMutability": "nonpayable", "type": "function"}, {"constant": false, "inputs": [{"name": "_value", "type": "uint256"}], "name": "burn", "outputs": [{"name": "", "type": "bool"}], "payable": false, "stateMutability": "nonpayable", "type": "function"}, {"constant": true, "inputs": [], "name": "getETHBalance", "outputs": [{"name": "", "type": "uint256"}], "payable": false, "stateMutability": "view", "type": "function"}, {"constant": true, "inputs": [{"name": "", "type": "address"}], "name": "balanceOf", "outputs": [{"name": "", "type": "uint256"}], "payable": false, "stateMutability": "view", "type": "function"}, {"constant": false, "inputs": [{"name": "_from", "type": "address"}, {"name": "_value", "type": "uint256"}, {"name": "key", "type": "string"}], "name": "burnTransfer", "outputs": [{"name": "", "type": "bool"}], "payable": false, "stateMutability": "nonpayable", "type": "function"}, {"constant": false, "inputs": [{"name": "_from", "type": "address"}, {"name": "_value", "type": "uint256"}], "name": "burnFrom", "outputs": [{"name": "", "type": "bool"}], "payable": false, "stateMutability": "nonpayable", "type": "function"}, {"constant": false, "inputs": [{"name": "_to", "type": "address"}, {"name": "_value", "type": "uint256"}], "name": "transferETH", "outputs": [{"name": "", "type": "bool"}], "payable": true, "stateMutability": "payable", "type": "function"}, {"constant": false, "inputs": [{"name": "key", "type": "string"}, {"name": "_burnPoolAddress", "type": "address"}], "name": "setBurnPoolAddress", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function"}, {"constant": true, "inputs": [], "name": "owner", "outputs": [{"name": "", "type": "address"}], "payable": false, "stateMutability": "view", "type": "function"}, {"constant": false, "inputs": [{"name": "_to", "type": "address[]"}, {"name": "_value", "type": "uint256[]"}], "name": "transferArray", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function"}, {"constant": true, "inputs": [], "name": "symbol", "outputs": [{"name": "", "type": "string"}], "payable": false, "stateMutability": "view", "type": "function"}, {"constant": false, "inputs": [{"name": "_to", "type": "address"}, {"name": "_value", "type": "uint256"}], "name": "transfer", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function"}, {"constant": false, "inputs": [{"name": "_to", "type": "address"}, {"name": "_value", "type": "uint256"}], "name": "smTransfer", "outputs": [{"name": "", "type": "bool"}], "payable": false, "stateMutability": "nonpayable", "type": "function"}, {"constant": true, "inputs": [{"name": "key", "type": "string"}], "name": "getBurnPoolAddress", "outputs": [{"name": "", "type": "address"}], "payable": false, "stateMutability": "view", "type": "function"}, {"constant": false, "inputs": [{"name": "_spender", "type": "address"}, {"name": "_value", "type": "uint256"}, {"name": "_extraData", "type": "bytes"}], "name": "approveAndCall", "outputs": [{"name": "success", "type": "bool"}], "payable": false, "stateMutability": "nonpayable", "type": "function"}, {"constant": false, "inputs": [], "name": "funding", "outputs": [{"name": "", "type": "bool"}], "payable": true, "stateMutability": "payable", "type": "function"}, {"constant": false, "inputs": [{"name": "_adr", "type": "address"}], "name": "setOwnerContracts", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function"}, {"constant": true, "inputs": [], "name": "smPool", "outputs": [{"name": "", "type": "address"}], "payable": false, "stateMutability": "view", "type": "function"}, {"constant": false, "inputs": [{"name": "_to", "type": "address"}], "name": "transferETH", "outputs": [{"name": "", "type": "bool"}], "payable": true, "stateMutability": "payable", "type": "function"}, {"constant": true, "inputs": [{"name": "", "type": "address"}, {"name": "", "type": "address"}], "name": "allowance", "outputs": [{"name": "", "type": "uint256"}], "payable": false, "stateMutability": "view", "type": "function"}, {"constant": false, "inputs": [], "name": "transferETH", "outputs": [{"name": "", "type": "bool"}], "payable": true, "stateMutability": "payable", "type": "function"}, {"constant": true, "inputs": [], "name": "setCount", "outputs": [{"name": "", "type": "uint8"}], "payable": false, "stateMutability": "view", "type": "function"}, {"constant": true, "inputs": [{"name": "", "type": "uint256"}], "name": "ownerContracts", "outputs": [{"name": "", "type": "address"}], "payable": false, "stateMutability": "view", "type": "function"}, {"inputs": [{"name": "initialSupply", "type": "uint256"}, {"name": "tokenName", "type": "string"}, {"name": "tokenSymbol", "type": "string"}], "payable": true, "stateMutability": "payable", "type": "constructor"}, {"payable": true, "stateMutability": "payable", "type": "fallback"}, {"anonymous": false, "inputs": [{"indexed": true, "name": "from", "type": "address"}, {"indexed": true, "name": "to", "type": "address"}, {"indexed": false, "name": "value", "type": "uint256"}], "name": "Transfer", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": true, "name": "from", "type": "address"}, {"indexed": true, "name": "to", "type": "address"}, {"indexed": false, "name": "value", "type": "uint256"}], "name": "TransferETH", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": true, "name": "from", "type": "address"}, {"indexed": false, "name": "value", "type": "uint256"}], "name": "Burn", "type": "event"}]}
1 change: 1 addition & 0 deletions cache/BAT.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"address": "0x0d8775f648430679a709e98d2b0cb6250d2887ef", "abi": [{"constant": true, "inputs": [], "name": "batFundDeposit", "outputs": [{"name": "", "type": "address"}], "payable": false, "type": "function"}, {"constant": true, "inputs": [], "name": "name", "outputs": [{"name": "", "type": "string"}], "payable": false, "type": "function"}, {"constant": false, "inputs": [{"name": "_spender", "type": "address"}, {"name": "_value", "type": "uint256"}], "name": "approve", "outputs": [{"name": "success", "type": "bool"}], "payable": false, "type": "function"}, {"constant": true, "inputs": [], "name": "totalSupply", "outputs": [{"name": "", "type": "uint256"}], "payable": false, "type": "function"}, {"constant": true, "inputs": [], "name": "batFund", "outputs": [{"name": "", "type": "uint256"}], "payable": false, "type": "function"}, {"constant": false, "inputs": [{"name": "_from", "type": "address"}, {"name": "_to", "type": "address"}, {"name": "_value", "type": "uint256"}], "name": "transferFrom", "outputs": [{"name": "success", "type": "bool"}], "payable": false, "type": "function"}, {"constant": true, "inputs": [], "name": "decimals", "outputs": [{"name": "", "type": "uint256"}], "payable": false, "type": "function"}, {"constant": true, "inputs": [], "name": "tokenExchangeRate", "outputs": [{"name": "", "type": "uint256"}], "payable": false, "type": "function"}, {"constant": false, "inputs": [], "name": "finalize", "outputs": [], "payable": false, "type": "function"}, {"constant": true, "inputs": [], "name": "version", "outputs": [{"name": "", "type": "string"}], "payable": false, "type": "function"}, {"constant": false, "inputs": [], "name": "refund", "outputs": [], "payable": false, "type": "function"}, {"constant": true, "inputs": [], "name": "tokenCreationCap", "outputs": [{"name": "", "type": "uint256"}], "payable": false, "type": "function"}, {"constant": true, "inputs": [{"name": "_owner", "type": "address"}], "name": "balanceOf", "outputs": [{"name": "balance", "type": "uint256"}], "payable": false, "type": "function"}, {"constant": true, "inputs": [], "name": "isFinalized", "outputs": [{"name": "", "type": "bool"}], "payable": false, "type": "function"}, {"constant": true, "inputs": [], "name": "fundingEndBlock", "outputs": [{"name": "", "type": "uint256"}], "payable": false, "type": "function"}, {"constant": true, "inputs": [], "name": "symbol", "outputs": [{"name": "", "type": "string"}], "payable": false, "type": "function"}, {"constant": true, "inputs": [], "name": "ethFundDeposit", "outputs": [{"name": "", "type": "address"}], "payable": false, "type": "function"}, {"constant": false, "inputs": [{"name": "_to", "type": "address"}, {"name": "_value", "type": "uint256"}], "name": "transfer", "outputs": [{"name": "success", "type": "bool"}], "payable": false, "type": "function"}, {"constant": false, "inputs": [], "name": "createTokens", "outputs": [], "payable": true, "type": "function"}, {"constant": true, "inputs": [], "name": "tokenCreationMin", "outputs": [{"name": "", "type": "uint256"}], "payable": false, "type": "function"}, {"constant": true, "inputs": [], "name": "fundingStartBlock", "outputs": [{"name": "", "type": "uint256"}], "payable": false, "type": "function"}, {"constant": true, "inputs": [{"name": "_owner", "type": "address"}, {"name": "_spender", "type": "address"}], "name": "allowance", "outputs": [{"name": "remaining", "type": "uint256"}], "payable": false, "type": "function"}, {"inputs": [{"name": "_ethFundDeposit", "type": "address"}, {"name": "_batFundDeposit", "type": "address"}, {"name": "_fundingStartBlock", "type": "uint256"}, {"name": "_fundingEndBlock", "type": "uint256"}], "payable": false, "type": "constructor"}, {"anonymous": false, "inputs": [{"indexed": true, "name": "_to", "type": "address"}, {"indexed": false, "name": "_value", "type": "uint256"}], "name": "LogRefund", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": true, "name": "_to", "type": "address"}, {"indexed": false, "name": "_value", "type": "uint256"}], "name": "CreateBAT", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": true, "name": "_from", "type": "address"}, {"indexed": true, "name": "_to", "type": "address"}, {"indexed": false, "name": "_value", "type": "uint256"}], "name": "Transfer", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": true, "name": "_owner", "type": "address"}, {"indexed": true, "name": "_spender", "type": "address"}, {"indexed": false, "name": "_value", "type": "uint256"}], "name": "Approval", "type": "event"}]}
Loading

0 comments on commit 5f11a3d

Please sign in to comment.