gpt4 book ai didi

coinbase-api - Coinbase API:为具有电子邮件地址的用户创建新的比特币钱包

转载 作者:行者123 更新时间:2023-12-02 04:49:08 27 4
gpt4 key购买 nike

你们知道Coinbase是否允许Xapo那样通过其Api自动创建用户吗?
基本上,我需要为Web应用程序上的用户生成一个钱包地址。
欢迎任何创新的想法或替代方案,如果不可能的话!
谢谢

最佳答案

这就是我在Rails应用程序中所做的事情。

def create_account
wallet = Coinbase::Wallet::Client.new(api_key: ENV["COINBASE_KEY"], api_secret: ENV["COINBASE_SECRET"])
mAccount = check_account
if mAccount.nil?
mAccount = wallet.create_account(name: self.email)
end
newaddr = mAccount.create_address
newaddr = newaddr["address"]
account = Account.new
account.address = newaddr
account.user_id = self.id
account.balance = mAccount["balance"]["amount"]
account.account_id = mAccount["id"]
account.save
end
def check_account
begin
wallet = Coinbase::Wallet::Client.new(api_key: ENV["COINBASE_KEY"], api_secret: ENV["COINBASE_SECRET"])
ac = nil
a = wallet.accounts
a.each do |account|
if account["name"] == self.email
ac = wallet.account(account["id"])
end
end
ac
rescue Coinbase::Wallet::NotFoundError
nil
end
end

关于coinbase-api - Coinbase API:为具有电子邮件地址的用户创建新的比特币钱包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30433282/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com