Ctrl+Shift+Del 清除Google浏览器缓存的快捷键
Ctrl+Shift+R 重新加载当前网页而不使用缓存内容
Ctrl + F5 去除缓存+刷新快捷键
chrome清除缓存、不使用缓存而刷新快捷键
Cosmos钱包管理和离线交易签名工具
github: https://github.com/hukkinj1/cosmospy
cosmospy
Version 5.0.1
Tools for Cosmos wallet management and offline transaction signing
Installing
Installing from PyPI repository (https://pypi.org/project/cosmospy):
pip install cosmospy
Usage
Generating a wallet
from cosmospy import generate_wallet
wallet = generate_wallet()
The value assigned to wallet
will be a dictionary just like:
{
"seed": "arch skill acquire abuse frown reject front second album pizza hill slogan guess random wonder benefit industry custom green ill moral daring glow elevator",
"derivation_path": "m/44'/118'/0'/0/0",
"private_key": b"\xbb\xec^\xf6\xdcg\xe6\xb5\x89\xed\x8cG\x05\x03\xdf0:\xc9\x8b \x85\x8a\x14\x12\xd7\xa6a\x01\xcd\xf8\x88\x93",
"public_key": b"\x03h\x1d\xae\xa7\x9eO\x8e\xc5\xff\xa3sAw\xe6\xdd\xc9\xb8b\x06\x0eo\xc5a%z\xe3\xff\x1e\xd2\x8e5\xe7",
"address": "cosmos1uuhna3psjqfxnw4msrfzsr0g08yuyfxeht0qfh",
}
Converter functions
Mnemonic seed to private key
from cosmospy import seed_to_privkey
seed = "teach there dream chase fatigue abandon lava super senior artefact close upgrade"
privkey = seed_to_privkey(seed, path="m/44'/118'/0'/0/0")
Private key to public key
from cosmospy import privkey_to_pubkey
privkey = bytes.fromhex("6dcd05d7ac71e09d3cf7da666709ebd59362486ff9e99db0e8bc663570515afa")
pubkey = privkey_to_pubkey(privkey)
Public key to address
from cosmospy import pubkey_to_address
pubkey = bytes.fromhex("03e8005aad74da5a053602f86e3151d4f3214937863a11299c960c28d3609c4775")
addr = pubkey_to_address(pubkey)
Private key to address
from cosmospy import privkey_to_address
privkey = bytes.fromhex("6dcd05d7ac71e09d3cf7da666709ebd59362486ff9e99db0e8bc663570515afa")
addr = privkey_to_address(privkey)
Signing transactions
from cosmospy import Transaction
tx = Transaction(
privkey=bytes.fromhex("26d167d549a4b2b66f766b0d3f2bdbe1cd92708818c338ff453abde316a2bd59"),
account_num=11335,
sequence=0,
fee=1000,
gas=70000,
memo="",
chain_id="cosmoshub-3",
sync_mode="sync",
)
tx.add_transfer(recipient="cosmos103l758ps7403sd9c0y8j6hrfw4xyl70j4mmwkf", amount=387000)
tx.add_transfer(recipient="cosmos1lzumfk6xvwf9k9rk72mqtztv867xyem393um48", amount=123)
pushable_tx = tx.get_pushable()
One or more token transfers can be added to a transaction by calling the add_transfer
method.
When the transaction is fully prepared, calling get_pushable
will return a signed transaction in the form of a JSON string. This can be used as request body when calling the POST /txs
endpoint of the Cosmos REST API.
让区块链浏览器收录你的 ERC20 代币
如果想让其他浏览器显示新发的代币,需要主动提交代币信息,对方审核通过后,即可显示。
打开网址https://etherscan.io,在此处输入 token 的智能合约地址,如下图:
搜索后,如下图:
按下图指示,点击“verify and publish”来发布代码,
由于读者已经发布了代码,这里就找了几张图贴出来,以供参考。
步骤一:
步骤二:
步骤三:
若出现如下图,即表示收录成功。
Eosplayer -> eosjs的绑定层
Eosplayer是eosjs的绑定层,它基于eosjs并为应用程序层提供了更好的可用性。它既可以在node.js服务器上使用,也可以在已经安装了Scatter的浏览器或Dapp钱包中使用。
frontd releases : https://github.com/bagaking/eosplayer/releases
演示地址:http://eosplayer.kihand.com/#/
Web3j send ERC20 Token Demo
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="../../libs/web3.js_v1.0.0-beta.35/web3.min.js"></script>
</head>
<body>
<h1>Send ERC20 Token</h1>
<h2>Notes</h2>
<ul>
<li>Use MetaMask</li>
<li>To check ERC20 balance, use <a href="../getERC20TokenBalance/" target="_blank">getERC20TokenBalance</a></li>
</ul>
<h2>Token Address</h2>
<input type="text" id="token-address" size="80" oninput="onAddressChange()"></input>
<p>e.g. 0x2A65D41dbC6E8925bD9253abfAdaFab98eA53E34</p>
<h2>Recipients Address</h2>
<input type="text" id="to-address" size="80"></input>
<p>e.g. 0x8Df70546681657D6FFE227aB51662e5b6e831B7A</p>
<h2>Decimals</h2>
<input type="number" id="decimals" size="40" readonly></input>
<h2>Amount</h2>
<input type="number" id="amount" size="40"></input>
<div><button id="send" onclick="send()">Send ERC20 Token</button></div>
<h2>Result</h2>
<span id="result"></span>
<script>
var web3js;
var account;
function getERC20TokenBalance(tokenAddress, walletAddress, callback) {
let minABI = [
{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"type":"function"},
{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"type":"function"}
];
let contract = new web3js.eth.Contract(minABI, tokenAddress);
contract.methods.balanceOf(walletAddress).call((error, balance) => {
contract.methods.decimals().call((error, decimals) => {
console.log(balance);
console.log(decimals);
balance = balance / (10**decimals);
callback(balance);
});
});
}
function getERC20TokenContract(tokenAddress) {
let minABI = [
{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"type":"function"},
{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"type":"function"},
{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"type":"function"}
];
return new web3js.eth.Contract(minABI, tokenAddress);
}
function getERC20TokenDecimals(callback) {
window.tokenContract.methods.decimals().call((error, decimals) => {
callback(decimals);
});
}
function onAddressChange(e) {
let tokenAddress = document.getElementById('token-address').value;
if(tokenAddress != "") {
window.tokenContract = getERC20TokenContract(tokenAddress);
getERC20TokenDecimals((decimals) => {
document.getElementById('decimals').value = decimals;
});
}
}
function transferERC20Token(toAddress, value, callback) {
window.tokenContract.methods.transfer(toAddress, value).send({from: account})
.on('transactionHash', function(hash){
callback(hash);
});
}
function send() {
var toAddress = document.getElementById('to-address').value;
var decimals = web3js.utils.toBN(document.getElementById('decimals').value);
var amount = web3js.utils.toBN(document.getElementById('amount').value);
var sendValue = amount.mul(web3js.utils.toBN(10).pow(decimals));
console.log(sendValue.toString());
transferERC20Token(toAddress, sendValue, (txHash) => {
document.getElementById('result').innerText = txHash;
});
}
window.onload = function() {
web3js = new Web3(Web3.givenProvider);
console.log(web3js.version);
var accountInterval = setInterval(function() {
web3js.eth.getAccounts((error, address) => {
if (address[0] !== account) {
account = address[0];
console.log(account);
}
});
}, 300);
}
</script>
</body>
</html>
https://github.com/piyolab/sushiether/commit/e35e949b5d898d357f9bd1d4e3f35b679974f192