一、基于ERC20的USDT开发(go开发)
1、地址生成
func generateAddr() {
privateKey, err := crypto.GenerateKey()
if err != nil {
log.Fatal(err)
}
privateKeyBytes := crypto.FromECDSA(privateKey)
privateKeyStr := hexutil.Encode(privateKeyBytes)[2:]
log.Println("-String--private key ---", privateKeyStr)
publicKey := privateKey.Public()
publicKeyECDSA, ok := publicKey.(*ecdsa.PublicKey)
if !ok {
log.Fatal("error casting public key to ECDSA")
}
publicKeyBytes := crypto.FromECDSAPub(publicKeyECDSA)
publicKeyStr := hexutil.Encode(publicKeyBytes)[4:]
log.Println("-String--public key ---", publicKeyStr)
address := crypto.PubkeyToAddress(*publicKeyECDSA).Hex()
return privateKeyStr, publicKeyStr, address
}
2、提币
--------更新中----------
3、充币监控
—————-更新中—————————-
二、基于OMNI协议的USDT开发(nodejs开发)
1、地址生成
let randomBytes = require('randombytes');
let BigInteger = require('bigi');
let ecurve = require('ecurve');
let crypto = require('crypto');
let cs = require('coinstring');
function generateAddress() {
let secp256k1 = ecurve.getCurveByName('secp256k1')
let randombytes = randomBytes(32).toString('hex')
let privateKey = Buffer.from(randombytes, 'hex')
let ecparams = ecurve.getCurveByName('secp256k1')
let curvePt = ecparams.G.multiply(BigInteger.fromBuffer(privateKey))
let x = curvePt.affineX.toBuffer(32)
let y = curvePt.affineY.toBuffer(32)
let publicKey = Buffer.concat([Buffer.from([0x04]), x, y])
//compressed
publicKey = curvePt.getEncoded(true) //true forces compressed public key
console.log("压缩公钥 :" + publicKey.toString('hex'))
let sha = crypto.createHash('sha256').update(publicKey).digest()
let pubkeyHash = crypto.createHash('rmd160').update(sha).digest()
let address = cs.encode(pubkeyHash, 0x0)
// address of compressed public key
console.log("压缩地址:" + address) //<-- 0x0 is for public addresses
//校验和Base58编码
// let private_key2 = cs.encode(privateKey, 0x80) // private_key2 have some problem
// console.log(private_key2) //<--- 0x80 is for private addresses
let private_key = cs.encode(Buffer.concat([privateKey, new Buffer([0x01])]), 0x80)
console.log("压缩私钥:" + private_key) // <-- compressed private address
return [address, publicKey.toString('hex'), private_key]
}
module.exports = {
generateAddress
}
2、提币
—————-更新中—————————-