定制 agostinhobarbosa/stellar-api 二次开发

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

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

agostinhobarbosa/stellar-api

Composer 安装命令:

composer require agostinhobarbosa/stellar-api

包简介

API client for the Stellar network

README 文档

README

PHP Library for interacting with the Stellar network.

  • Communicate with Horizon server
  • Build and sign transactions

⚠️ Danger Zone ⚠️

Development Status

This library is under active development and should be considered beta quality. Please ensure that you've tested extensively on a test network and have added sanity checks in other places in your code.

⚠️ See the release notes for breaking changes

Large Integer Support

The largest PHP integer is 64-bits when on a 64-bit platform. This is especially important to pay attention to when working with large balance transfers. The native representation of a single XLM (1 XLM) is 10000000 stroops.

Therefore, if you try to use a MAX_INT number of XLM (or a custom asset) it is possible to overflow PHP's integer type when the value is converted to stroops and sent to the network.

This library attempts to add checks for this scenario and also uses a BigInteger class to work around this problem.

If your application uses large amounts of XLM or a custom asset please do extensive testing with large values and use the StellarAmount helper class or the BigInteger class if possible.

Floating point issues

Although not specific to Stellar or PHP, it's important to be aware of problems when doing comparisons between floating point numbers.

For example:

$oldBalance = 1.605;
$newBalance = 1.61;

var_dump($oldBalance + 0.005);
var_dump($newBalance);
if ($oldBalance + 0.005 === $newBalance) {
    print "Equal\n";
}
else {
    print "Not Equal\n";
}

The above code considers the two values not to be equal even though the same value is printed out:

Output:

float(1.61)
float(1.61)
Not Equal

To work around this issue, always work with and store amounts as an integer representing stroops. Only convert back to a decimal number when you need to display a balance to the user.

The static StellarAmount::STROOP_SCALE property can be used to help with this conversion.

Installation

To install the latest release for usage in your project:

cd your_project/
composer require zulucrypto/stellar-api

If you want to work with the most recent development version you can use this repository:

git clone https://github.com/zulucrypto/stellar-api.git
cd stellar-api/
composer install

Getting Started

See the getting-started directory for examples of how to use this library.

These examples are modeled after the ones in Stellar's getting started guide:

https://www.stellar.org/developers/guides/get-started/create-account.html

Additional examples are available in the examples directory

Donations

Stellar: GCUVDZRQ6CX347AMUUWZDYSNDFAWDN6FUYM5DVYYVO574NHTAUCQAK53

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 50
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-11-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固