Download the PHP package neto737/bitgosdk-php without Composer
On this page you can find all versions of the php package neto737/bitgosdk-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download neto737/bitgosdk-php
More information about neto737/bitgosdk-php
Files in neto737/bitgosdk-php
Package bitgosdk-php
Short Description PHP client for the BitGo API and BitGo Express: wallets, addresses, transfers, webhooks and sending coins.
License MIT
Homepage https://github.com/neto737/BitGoSDK-PHP
Informations about the package bitgosdk-php
BitGoSDK PHP
A PHP client for the BitGo API and BitGo Express.
Manage wallets, addresses, transfers, policies and webhooks, and send coins, from your PHP code.
Features
- Two clients:
BitGoSDKtalks to the BitGo API for wallets, addresses, transfers, keychains, policies, sharing, approvals and webhooks.BitGoExpresstalks to your own BitGo Express instance for anything that needs your keys, such as creating wallets and sending coins. - Any BitGo coin, mainnet or testnet, with
CurrencyCodeconstants for 95 coins and tokens andAddressTypeconstants for every UTXO address type. - Exact amounts: pass an
intor a string of digits, and amounts are always sent as strings.toBaseUnits()andfromBaseUnits()convert at any number of decimals without floats, so 18-decimal ETH amounts don't overflow. - Errors you can check: a failed call returns
['error' => …, 'status' => …]instead of throwing, so anisset($r['error'])check is all you need. - TLS verification on by default, against the system CA store, with a custom CA option for Express or a TLS-inspecting proxy.
- Request timeouts, opt-in IPv4 forcing and binding to a local IP.
- Plain PHP arrays as results. The only dependencies are
ext-curlandcomposer/ca-bundle. - Tested on PHP 7.4 to 8.5.
Requirements
- PHP 7.4 or later, with the cURL extension
- A BitGo account and an access token
- A BitGo Express instance, version 14.1.3 or later, for anything that needs your keys
Installation
Quick start
More examples are in examples/.
[!NOTE] Requests to Express carry wallet passphrases and private keys. Use plain
http://only when Express runs on the same host. Otherwise see Use TLS unless Express is on the same host.
What's covered
BitGoSDK: the BitGo API
| Area | Methods |
|---|---|
| User and session | getCurrentUserProfile(), getSessionInfo(), lockSession(), unlockSession(), logout() |
| Wallets | listWallets(), getWallet(), getWalletByAddress(), getTotalBalances(), getMaximumSpendable(), freezeWallet() |
| Addresses | createWalletAddress(), getWalletAddress(), getWalletAddresses(), updateWalletAddress() |
| Transfers and unspents | listWalletTransfers(), getWalletTransfer(), getWalletTransferBySequenceId(), getWalletTransactions(), getWalletTransaction(), listWalletUnspents() |
| Keychains | listKeychains(), getKeychain(), createBitGoKeychain(), createBackupKeychain(), addKeychain() |
| Policies | setVelocityPolicyRule(), updateVelocityPolicyRule(), removePolicyRule() |
| Wallet sharing | listWalletShares(), getWalletShare(), resendWalletShareInvite(), cancelWalletShare(), removeWalletUser() |
| Pending approvals | listPendingApprovals(), getPendingApproval() |
| Webhooks | Wallet and user webhooks: list…, add…, remove… and simulate…Webhook(). getWebhookPayload() reads an incoming webhook. |
| Fees and prices | estimateTransactionFees(), getMarketPriceData() |
| Amounts | toSatoshi(), toBTC(), toBaseUnits(), fromBaseUnits() |
BitGoExpress: your BitGo Express instance
| Area | Methods |
|---|---|
| Status and login | ping(), pingExpress(), login() |
| Wallets | generateWallet(), addWallet(), createKeychain() |
| Sending | sendTransaction(), sendTransactionToMany() |
| Build, sign and send in steps | buildTransaction(), signBuildTransaction(), sendBuildTransaction() |
| Unspent management | consolidateWalletUnspents(), fanoutWalletUnspents(), sweep() |
| Sharing and approvals | shareWallet(), acceptWalletShare(), updatePendingApproval() |
| Utilities | encrypt(), decrypt(), verifyAddress() |
Each method's parameters are documented in its docblock. For what each endpoint does, see the BitGo API reference and the Express API reference.
Error handling
Calls don't throw on API or network errors. They return an array with an error message and the HTTP status, plus any other fields BitGo sent:
buildTransaction() and signBuildTransaction() return the same fields as an object.
IDs and addresses you pass in are percent-encoded into the URL, so they can't change which endpoint a request reaches. An empty ID, . or .. would still reach a different endpoint, so the call throws an InvalidArgumentException instead of sending the request. So does any wallet method called before walletId is set.
Receiving webhooks
Anyone who knows your webhook URL can POST to it, so treat the payload as untrusted. Check that hash looks like a transaction hash, then look the transfer up on BitGo with getWalletTransaction() and act on what BitGo returns, not on the webhook body. examples/receiveWebhook.php shows how, and answers BitGo before the lookup so slow handlers don't trigger retries.
BitGo Express
BitGo signs transactions on the client, so sending coins, creating wallets and other calls that use your keys go through BitGoExpress, which talks to your own BitGo Express instance. See Install BitGo Express to run one.
Use TLS unless Express is on the same host
Over plain http://, Express is only safe when it listens on localhost. Otherwise, run Express with a TLS certificate and prefix the hostname with https://:
setCaFile() throws an InvalidArgumentException if the file can't be read. Certificates are verified by default. setVerifyTls(false) turns verification off, so use it only for local testing.
Minimum Express version
Use BitGo Express 14.1.3 or later. Older versions fail on two changes BitGo made on its side:
- UTXO withdrawals from cold wallets must use PSBT in production. BitGo needs Express 14.1.3 or later for this (changelog).
- Send-to-many on EVM assets (
sendTransactionToMany()on ETH and other EVM coins) uses a new batcher contract since May 22, 2025, so Express releases from before that date can't send it (changelog).
Client settings
Both clients have these settings:
BitGoSDK::setRequestIP('203.0.113.10') sends requests from that local IP. It returns false on testnet or for an invalid IP.
TLS certificates
Both clients check certificates against your system's CA store. If PHP can't find one, they use the Mozilla CA bundle from composer/ca-bundle, so keep your dependencies up to date. To trust a different CA, for example behind a TLS-inspecting proxy, call setCaFile('/path/to/ca.pem').
Documentation
Upgrading from 2.2.x? 2.3 keeps the same methods, but it needs PHP 7.4 or later, and two behaviours changed: 0 and false params are now sent, and errors come back as ['error' => …, 'status' => …]. Read the 2.3.0 changelog before you upgrade.
Upgrading from 2.3.0? 2.3.1 is a security fix (GHSA-qr36-39c2-hp84). Wallet methods now throw an InvalidArgumentException if walletId isn't set, so set it before you call them.
Contributing
Bug reports and pull requests are welcome. See CONTRIBUTING.md for the branch model and release process. To run the checks:
Each check can also run on its own: composer test (PHPUnit), composer analyse (PHPStan) and composer cs (PHP-CS-Fixer). composer cs:fix fixes the coding style. The code follows PSR-12, with 4-space indentation and LF line endings.
The tests replace the HTTP transport with a recorder, so they don't need a BitGo account or network access.
To report a security issue, follow SECURITY.md instead of opening a public issue.
Credits
Created and maintained by Neto Melo.
This is a community project. It is not affiliated with or endorsed by BitGo, Inc.
Support the project :heart:
If this library saves you time, you can support its development via Liberapay, PayPal or crypto:
License
Released under the MIT License. Versions 2.2.3 and earlier were released under GPL-3.0.
All versions of bitgosdk-php with dependencies
ext-json Version *
php-http/discovery Version ^1.20
psr/http-client Version ^1.0
psr/http-client-implementation Version ^1.0
psr/http-factory Version ^1.1
psr/http-factory-implementation Version ^1.0
psr/http-message Version ^1.1 || ^2.0