定制 he426100/filecoin-tx 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

he426100/filecoin-tx

最新稳定版本:0.0.2

Composer 安装命令:

composer require he426100/filecoin-tx

包简介

Filecoin transaction library in PHP

README 文档

README

此项目源自 https://github.com/yuminuo/filecoin-tx

Filecoin transaction library in PHP(Only for secp256k1).

Install

composer require he426100/filecoin-tx

Usage

sign

Returns signed of transaction data.

sign(array $message, string $privateKey)

Example
  • Sign the transaction data.
use He426100\FilecoinTx\Sign;

$fromAddress = 't1hb4737umuzzbcfd3xxk3bdtwezgistj7dycypvi';
$rpc = new Rpc(...);
$nonce = $rpc->request('MpoolGetNonce', $fromAddress);

$message = [
    'Version' => 0,
    'From' => $fromAddress,
    'To' => 't1qkqqbmrbhsvjdturbalnyb3tudqxtmbp6x7ohry',
    'Value' => '100000000000000000', // 此参数必须是字符串 0.1 FIL
    'Method' => 0, // 表示send
    'Nonce' => $nonce, // 交易序号,用接口 MpoolGetNonce 获取
    'Params' => '', // base64 编码数据
    'GasLimit' => 0, // 可用接口估算 GasEstimateGasLimit
    'GasPremium' => "0", // 此参数必须是字符串,可用接口估算 GasEstimateGasPremium
    'GasFeeCap' => "0" // 此参数必须是字符串,可用接口估算 GasEstimateFeeCap
];

$gas = $rpc->request('GasEstimateMessageGas', $message, ['MaxFee' => bcmul('0.1', bcpow(10, 18))], null);
$message['GasPremium'] = $gas['GasPremium'];
$message['GasFeeCap'] = $gas['GasFeeCap'];
$message['GasLimit'] = $gas['GasLimit'];

$sign = new Sign();
$signData = $sign->sign($message, "ee2868ca9485673b36c38ba4f18551be25d08dd9be9bd24c44cd626b37cadae4");
//获取messageID
$message['cid'] = ['/' => $sign->getMessageId()];
//获取离线计算发送返回CID
$sign->getCid();
$signMessageData = [
    'message' => $message,
    'signature' => [
        'data' => $signData,
        'type' => 1 //SECP256K1=1
    ]
];

License

MIT

统计信息

  • 总下载量: 13
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-07-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固