资源加载中... loading...

币安 提币范例代码

Author: 发明者量化-小小梦, Date: 2019-05-16 09:29:37
Tags: ToolBinance


String.prototype.format= function(){
    var args = Array.prototype.slice.call(arguments);
    var count=0;
    return this.replace(/%s/g,function(s,i){
        return args[count++];
    });
}

function WithdrawForBinance (accessKey, currency, address, addressTag, amount) {
    /* Withdraw API desc on Binance API doc
        query string :
            asset=ETH&address=0x6915f16f8791d0a1cc2bf47c13a6b2a92000504b&amount=1&recvWindow=5000&name=test&timestamp=1510903211000
        HMAC SHA256 signature:
            [linux]$ echo -n "asset=ETH&address=0x6915f16f8791d0a1cc2bf47c13a6b2a92000504b&amount=1&recvWindow=5000&timestamp=1510903211000" | 
            openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j"
            (stdin)= 157fb937ec848b5f802daa4d9f62bea08becbf4f311203bda2bd34cd9853e320
        curl command:
            (HMAC SHA256)
            [linux]$ curl -H "X-MBX-APIKEY: vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A" -X 
            POST 'https://www.binance.com/wapi/v3/withdraw.html?
            asset=ETH&address=0x6915f16f8791d0a1cc2bf47c13a6b2a92000504b&amount=1&recvWindow=5000&name=addressName&timestamp=1510903211000&
            signature=157fb937ec848b5f802daa4d9f62bea08becbf4f311203bda2bd34cd9853e320'
    */
    
    var timeStamp = new Date().getTime()
    var queryString = "asset=%s&address=%s&amount=%s&name=%s&timestamp=%s"
    queryString = queryString.format(currency, address, amount, addressTag, timeStamp)
    
    // sign
    var signature = exchange.HMAC("sha256", "hex", queryString, "{{secretkey}}")
    var uri = "https://www.binance.com/wapi/v3/withdraw.html?" + queryString + "&signature=" + signature
    
    // request
    var ret = HttpQuery(uri, "", "", "X-MBX-APIKEY: " + accessKey, true)
    
    Log(ret)
}




function main() {
    WithdrawForBinance("your accessKey", "ETH", "the address that you want to send", "test", "0.01")
}
template: strategy.tpl:40:21: executing "strategy.tpl" at <.api.GetStrategyListByName>: wrong number of args for GetStrategyListByName: want 7 got 6