摘要:比特幣的到帳時間是個區(qū)塊的高度,約分鐘。請注意,比特幣與的地址是一樣的。
方案一: 通過ExinCore API進(jìn)行幣幣交易
Exincore 提供了基于Mixin Network的幣幣交易API.
你可以支付USDT給ExinCore, ExinCore會以最低的價格,最優(yōu)惠的交易費將你購買的比特幣轉(zhuǎn)給你, 每一幣交易都是匿名的,并且可以在區(qū)塊鏈上進(jìn)行驗證,交易的細(xì)節(jié)只有你與ExinCore知道!
ExinCore 也不知道你是誰,它只知道你的UUID.
預(yù)備知識:你先需要創(chuàng)建一個機(jī)器人, 方法在 教程一.
安裝依賴包正如教程一里我們介紹過的, 我們需要依賴 mixin-bot, 你應(yīng)該先安裝過它了, 這兒我們再安裝 easy-uuid, msgpack 兩個軟件包.
gem install msgpack gem install easy-uuid充幣到 Mixin Network, 并讀出它的余額.
ExinCore可以進(jìn)行BTC, USDT, EOS, ETH 等等交易, 這兒演示如果用 USDT購買BTC 或者 用BTC購買USDT, 交易前,先檢查一下錢包地址!
完整的步驟如下:
檢查比特幣或USDT的余額,錢包地址。并記下錢包地址。
從第三方交易所或者你的冷錢包中,將幣充到上述錢包地址。
再檢查一下幣的余額,看到帳與否。(比特幣的到帳時間是5個區(qū)塊的高度,約100分鐘)。
請注意,比特幣與USDT的地址是一樣的。
if cmd == "aw" assetsInfo = walletAccount.read_assets() p "--------The Wallet Assets List-----------------" assetsInfo["data"].each { |x| puts x["symbol"] + " " + x["balance"] + " " + x["public_key"] + x["account_name"] + " " + x["account_tag"]} p "----------End of Wallet Assets --------------" end查詢ExinCore市場的價格信息
如果來查詢ExinCore市場的價格信息呢?你要先了解你交易的基礎(chǔ)幣是什么,如果你想買比特幣,賣出USDT,那么基礎(chǔ)貨幣就是USDT;如果你想買USDT,賣出比特幣,那么基礎(chǔ)貨幣就是比特幣.
if cmd == "8" Utils.ExinCoreMarketPriceRequest(USDT_ASSET_ID) end if cmd == "9" Utils.ExinCoreMarketPriceRequest(BTC_ASSET_ID) end def self.ExinCoreMarketPriceRequest(asset_id) full_url = "https://exinone.com/exincore/markets?base_asset=" + asset_id p full_url data = HTTP.get(full_url).body body = "" redData = data.readpartial while redData != nil body = body + redData redData = data.readpartial end result = ActiveSupport::JSON.decode(body).with_indifferent_access result["data"].each { |x| puts x["exchange_asset_symbol"] + "/" + x["base_asset_symbol"] + " " + x["price"] + " " + x["minimum_amount"] + " " + x["maximum_amount"] + " " + x["exchanges"][0] } end交易前,創(chuàng)建一個Memo!
在第二章里,基于Mixin Network的Ruby比特幣開發(fā)教程: 機(jī)器人接受比特幣并立即退還用戶, 我們學(xué)習(xí)過退還用戶比特幣,在這里,我們除了給ExinCore支付幣外,還要告訴他我們想購買的幣是什么,即將想購買的幣存到memo里。
memo1 = Base64.encode64(MessagePack.pack({ "A" => UUID.parse(USDT_ASSET_ID).to_raw })) memo = memo1.sub(" ","")幣幣交易的完整流程
轉(zhuǎn)幣給ExinCore時,將memo寫入你希望購買的幣, 這個memo別錯了,否則,ExinCore需要人工操作來退幣!
如果你想賣出比特幣買入USDT,調(diào)用方式如下:
const EXIN_BOT = "61103d28-3ac2-44a2-ae34-bd956070dab1"; const BTC_ASSET_ID = "c6d0c728-2624-429b-8e0d-d9d19b6592fa"; const EOS_ASSET_ID = "6cfe566e-4aad-470b-8c9a-2fd35b49c68d"; const USDT_ASSET_ID = "815b0b1a-2764-3736-8faa-42d694fa620a"; if cmd == "5" memo1 = Base64.encode64(MessagePack.pack({ "A" => UUID.parse(USDT_ASSET_ID).to_raw })) memo = memo1.sub(" ","") p memo transInfo = walletAccount.create_transfer(walletAccount.encrypt_pin(DEFAULT_PIN), { asset_id: BTC_ASSET_ID, opponent_id: EXIN_BOT, amount: "0.0001", trace_id: SecureRandom.uuid, memo: memo }) p transInfo end
如果你想賣出USDT買入比特幣,調(diào)用方式如下:
if cmd == "6" memo1 = Base64.encode64(MessagePack.pack({ "A" => UUID.parse(BTC_ASSET_ID).to_raw })) memo = memo1.sub(" ","") p memo transInfo = walletAccount.create_transfer(walletAccount.encrypt_pin(DEFAULT_PIN), { asset_id: USDT_ASSET_ID, opponent_id: EXIN_BOT, amount: "1", trace_id: SecureRandom.uuid, memo: memo }) p transInfo end
交易完成后,Exincore會將你需要的幣轉(zhuǎn)到你的帳上,同樣,會在memo里,記錄成交價格,交易費用等信息!你只需要按下面的方式解開即可!
read_snapshots 讀取錢包的交易記錄。
if cmd == "7" if wallet_userid == "5e4ad097-21e8-3f6b-98f7-9dc74dd99f77" dt = "2019-05-23T09:48:04.582099Z" else puts "Input the snapshots datetime: " dt = gets.chomp end p CGI.escape(dt) snaps = walletAccount.read_snapshots({ limit: "10", offset: CGI.escape(dt), asset: BTC_ASSET_ID, order: "ASC" }) snaps["data"].each { |x| if x["amount"].to_f > 0 if x["data"] != nil uData = MessagePack.unpack(Base64.decode64(x["data"])) p uData p "The code is " + uData["C"].to_s + " Price is " + uData["P"] + " Fee is " + uData["F"] p "Fee is Asset UUID is " + UUID.parse(uData["FA"]).to_s p "Order id is " + UUID.parse(uData["O"]).to_s end end } end
一次成功的交易如下:
Make your choose(eg: q for Exit!): 7 "2019-05-23T09%3A48%3A04.582099Z" {"C"=>1000, "P"=>"7562.91", "F"=>"0.000000264", "FA"=>"xC6xD0xC7(&$Bx9Bx8E xD9xD1x9Bex92xFA", "T"=>"R", "O"=>"xC4x00*axF1xB1C9xBCxCE%xC3Cx88^R"} "The code is 1000 Price is 7562.91 Fee is 0.000000264" "Fee is Asset UUID is c6d0c728-2624-429b-8e0d-d9d19b6592fa" "Order id is c4002a07-f1b1-4339-bcce-25c343885e52" -------------------------------------------------------------------------讀取幣的余額
通過讀取幣的余額,來確認(rèn)交易情況!
if cmd == "aw" assetsInfo = walletAccount.read_assets() p "--------The Wallet Assets List-----------------" assetsInfo["data"].each { |x| puts x["symbol"] + " " + x["balance"] + " " + x["public_key"] + x["account_name"] + " " + x["account_tag"]} p "----------End of Wallet Assets --------------" end源代碼執(zhí)行
執(zhí)行 ruby bitcoin_wallet-ruby.rb 即可開始交易了.
1: Create Bitcoin Wallet and update PIN
2: Read Bitcoin balance & address
3: Read USDT balance & address
4: Read EOS balance & address
tbb:Transfer BTC from Bot to Wallet
tbm:Transfer BTC from Wallet to Master
teb:Transfer EOS from Bot to Wallet
tem:Transfer EOS from Wallet to Master
tub:Transfer USDT from Bot to Wallet
tum:Transfer USDT from Wallet to Master
tcb:Transfer CNB from Bot to Wallet
tcm:Transfer CNB from Wallet to Master
5: Pay 0.0001 BTC to ExinCore buy USDT
6: Pay $1 USDT to ExinCore buy BTC
7: Read Snapshots
8: Fetch market price(USDT)
9: Fetch market price(BTC)
ab: Read Bot Assets
aw: Read Wallet Assets
q: Exit
Make your choose(eg: q for Exit!):
完整代碼
Solution Two: List your order on Ocean.One exchange文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請注明本文地址:http://m.specialneedsforspecialkids.com/yun/24698.html
摘要:比特幣的到帳時間是個區(qū)塊的高度,約分鐘。請注意,比特幣與的地址是一樣的。 showImg(https://segmentfault.com/img/remote/1460000018419614?w=1200&h=659); 方案一: 通過ExinCore API進(jìn)行幣幣交易 Exincore 提供了基于Mixin Network的幣幣交易API. 你可以支付USDT給ExinCore...
摘要:方案二掛單交易所是基于的去中心化交易所,它性能一流。完整的步驟如下檢查比特幣或的余額,錢包地址。比特幣的到帳時間是個區(qū)塊的高度,約分鐘。 showImg(https://segmentfault.com/img/remote/1460000019234638?w=1200&h=659);上一章介紹了Exincore,你可以1秒完成資產(chǎn)的市價買賣。如果你想限定價格買賣,或者買賣一些exi...
摘要:是一個免費的極速的端對端加密數(shù)字貨幣交易系統(tǒng)官方資源匯總課程簡介創(chuàng)建一個機(jī)器人比特幣開發(fā)教程機(jī)器人接受比特幣并立即退還用戶比特幣開發(fā)教程創(chuàng)建比特幣錢包買賣實時兌換買賣在自由市場掛單買賣買賣任意在自由市場掛單買賣其他編程語言匯總比特幣開發(fā)教程 showImg(https://segmentfault.com/img/remote/1460000019234638?w=1200&h=659...
摘要:課程簡介創(chuàng)建一個機(jī)器人機(jī)器人接受比特幣并立即退還用戶創(chuàng)建比特幣錢包買賣實時兌換買賣在自由市場掛單買賣買賣任意在自由市場掛單買賣其他編程語言比特幣開發(fā)教程如下比特幣開發(fā)教程比特幣開發(fā)教程比特幣開發(fā)教程比特幣開發(fā)教程比特幣開發(fā)教程比特幣開發(fā)教程 showImg(https://segmentfault.com/img/bVboFQ6?w=1200&h=659); 課程簡介 PHP 創(chuàng)建一...
摘要:課程簡介創(chuàng)建一個機(jī)器人機(jī)器人接受比特幣并立即退還用戶創(chuàng)建比特幣錢包買賣實時兌換買賣在自由市場掛單買賣買賣任意在自由市場掛單買賣其他編程語言比特幣開發(fā)教程如下比特幣開發(fā)教程比特幣開發(fā)教程比特幣開發(fā)教程比特幣開發(fā)教程比特幣開發(fā)教程比特幣開發(fā)教程 showImg(https://segmentfault.com/img/bVboFQ6?w=1200&h=659); 課程簡介 PHP 創(chuàng)建一...
閱讀 3758·2021-08-11 11:16
閱讀 1626·2019-08-30 15:44
閱讀 1998·2019-08-29 18:45
閱讀 2274·2019-08-26 18:18
閱讀 1005·2019-08-26 13:37
閱讀 1571·2019-08-26 11:43
閱讀 2119·2019-08-26 11:34
閱讀 379·2019-08-26 10:59