Do you guys know if Coinbase allows for automatic creation of users through their Api the way Xapo does ? Basically I need to generate a wallet address for users on a web app . Any innovative ideas or alternatives if not possible are welcome !!! Thanks
Asked
Active
Viewed 1,158 times
1 Answers
0
This is what I'm doing in my Rails app.
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

Mr Smith
- 331
- 1
- 4
- 14