open-platform/open-wallet-php

开放平台钱包PHP库

dev-main 2023-05-01 12:50 UTC

This package is not auto-updated.

Last update: 2024-09-29 14:11:54 UTC


README

PHP 5.6.0及以后版本。

依赖项

安装OPEN信任钱包库

步骤 1 - 克隆仓库

git clone https://github.com/OpenFuturePlatform/wallet-core.git

步骤 2 - 构建Open库

cd wallet-core/open-platform/core-cpp
cmake . -DWALLET_CORE=../../
make

步骤 3 - 复制Open库

将共享库复制到"/usr/lib"允许在任意地方使用它

sudo cp libOpenWallet.so /usr/lib
sudo chmod 0755 /usr/lib/libOpenWallet.so

步骤 4 - 安装PHP-CPP库

PHP-CPP库是一个用于开发PHP扩展的C++库。https://github.com/CopernicaMarketingSoftware/PHP-CPP

cd wallet-core/open-platform/php/php-cpp
make
sudo make install

步骤 5 - 构建OPEN PHP扩展

cd wallet-core/open-platform/php
make
sudo make install	

入门指南

require_once('lib/OPEN.php');

$open = new OPEN();
$open->setApiKey("op_api_key");
$open->setSecretKey("op_api_secret");

币种

0   -> BTC
60  -> ETH
144 -> XRP
195 -> TRX
354 -> DOT
501 -> SOL
714 -> BNB

生成新的区块链钱包

$result = $open->generateWallet($coinType, $saveAddress);

导入区块链钱包

$address = $open->importWallet($privateKey, $coinType);

获取地址的Nonce值

$nonce = $open->getNonce($address, $network);

签名交易

$signedTransaction = $open->sign($privateKey, $address, $chainId, $gasPrice, $gasLimit, $amount, $nonce);

广播交易

$trxHash = $open->broadcast($signedTransaction, $coinType);

使用密码加密数据

$encryptedData = $open->encrypt($privateKey, $password);

使用密码解密数据

$decryptedData = $open->decrypt($data, $password);

为用户生成钱包

$wallets = $open->generateUserWallet($userId, $webHookAddress, $coinTypes = array(), $isTest);

导入用户钱包

$wallets = $open->importUserWallet($userId, $webHookAddress, $isTest, $encryptedData, $address, $coinType, $metadata)

为订单生成钱包

$wallets = $open->generateOrderWallet($webHookAddress, $coinTypes = array(), $isTest, $orderId, $amount, $orderCurrency, $metadata);

导入订单钱包

$wallets = $open->importOrderWallet($webHookAddress, $orderId, $amount, $isTest, $orderCurrency, $encryptedData, $address, $coinType, $metadata);