Skip to content

Commit 81ea37d

Browse files
committed
Initial commit
1 parent bfe7d5b commit 81ea37d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+2586
-2
lines changed

.coveralls.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
service_name: travis-ci
2+
coverage_clover: build/logs/clover.xml
3+
json_path: coveralls-upload.json

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
composer.phar
22
/vendor/
33

4-
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
4+
# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
55
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
66
# composer.lock
7+
nbproject/
8+
build/
9+
infection.log
10+
.phpunit.result.cache

.travis.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
language: php
2+
3+
php:
4+
- 7.2
5+
- 7.3
6+
- 7.4
7+
- nightly
8+
9+
matrix:
10+
allow_failures:
11+
- php: nightly
12+
13+
install:
14+
- phpenv config-rm xdebug.ini || true
15+
- travis_retry composer install --prefer-dist -n
16+
17+
script:
18+
- mkdir -p build/logs
19+
- phpdbg -qrr vendor/bin/phpunit
20+
21+
after_success:
22+
- composer require php-coveralls/php-coveralls
23+
- travis_retry vendor/bin/php-coveralls -v

README.md

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,45 @@
1-
# php-ethereum-token
1+
# php-ethereum-token [![Build Status](https://travis-ci.org/kornrunner/php-ethereum-uttokenil.svg?branch=master)](https://travis-ci.org/kornrunner/php-ethereum-token) [![Build status](https://ci.appveyor.com/api/projects/status/d1qm90h668elbtc4/branch/master?svg=true)](https://ci.appveyor.com/project/kornrunner/php-ethereum-token/branch/master) [![Coverage Status](https://coveralls.io/repos/github/kornrunner/php-ethereum-token/badge.svg?branch=master)](https://coveralls.io/github/kornrunner/php-ethereum-token?branch=master) [![Latest Stable Version](https://poser.pugx.org/kornrunner/ethereum-token/v/stable)](https://packagist.org/packages/kornrunner/ethereum-token)
2+
23
PHP Ethereum Token Utils
4+
5+
## Installation
6+
7+
```sh
8+
$ composer require kornrunner/ethereum-token
9+
```
10+
11+
## Usage
12+
13+
To prepare a offline transaction, using `kornrunner/ethereum-offline-raw-tx`
14+
15+
```php
16+
use kornrunner\Ethereum\Token;
17+
use kornrunner\Ethereum\Transaction;
18+
19+
$nonce = '04';
20+
$gasPrice = '03f5476a00';
21+
$gasLimit = '027f4b';
22+
$to = '1a8c8adfbe1c59e8b58cc0d515f07b7225f51c72';
23+
24+
$privateKey = 'b2f2698dd7343fa5afc96626dee139cb92e58e5d04e855f4c712727bf198e898';
25+
26+
$token = new Token;
27+
$usdt = new Token\USDT;
28+
29+
$amount = 20;
30+
$hexAmount = $token->hexAmount($usdt, $amount);
31+
// 0x1312d00
32+
33+
$data = $token->getTransferData($to, $hexAmount);
34+
// 0xa9059cbb0000000000000000000000001a8c8adfbe1c59e8b58cc0d515f07b7225f51c720000000000000000000000000000000000000000000000000000000001312d00
35+
36+
$transaction = new Transaction($nonce, $gasPrice, $gasLimit, $usdt::ADDRESS, $data);
37+
$transaction->getRaw($privateKey);
38+
// f8a9048503f5476a0083027f4b94dac17f958d2ee523a2206206994597c13d831ec7b844a9059cbb0000000000000000000000001a8c8adfbe1c59e8b58cc0d515f07b7225f51c720000000000000000000000000000000000000000000000000000000001312d00801ba03e141ea4233ec00bb3a80d7fea5f774b736772851b7bad18453d0f3c6097c42e9fa6eb47b6bead6a76d7db12809e2c916df999d7b99b613fcaa135abd8a0078e
39+
```
40+
41+
## Crypto
42+
43+
[![Ethereum](https://user-images.githubusercontent.com/725986/61891022-0d0c7f00-af09-11e9-829f-096c039bbbfa.png) 0x9c7b7a00972121fb843af7af74526d7eb585b171][Ethereum]
44+
45+
[Ethereum]: https://etherscan.io/address/0x9c7b7a00972121fb843af7af74526d7eb585b171 "Donate with Ethereum"

appveyor.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
build: false
2+
shallow_clone: true
3+
clone_folder: c:\php-ethereum-token
4+
platform: x64
5+
6+
cache:
7+
- c:\php -> appveyor.yml
8+
- vendor -> composer.lock
9+
10+
environment:
11+
matrix:
12+
- PHP_VERSION: '7.2.19'
13+
- PHP_VERSION: '7.3.7'
14+
15+
matrix:
16+
fast_finish: true
17+
18+
init:
19+
- SET PATH=c:\php\%PHP_VERSION%;%PATH%
20+
- set COMPOSER_NO_INTERACTION=1
21+
22+
install:
23+
- IF NOT EXIST c:\php mkdir c:\php
24+
- IF NOT EXIST c:\php\%PHP_VERSION% mkdir c:\php\%PHP_VERSION%
25+
- cd c:\php\%PHP_VERSION%
26+
- IF NOT EXIST php-installed.txt curl --fail --location --silent --show-error -o php.zip https://windows.php.net/downloads/releases/archives/php-%PHP_VERSION%-nts-Win32-VC15-x64.zip
27+
- IF NOT EXIST php-installed.txt 7z x php.zip -y
28+
- IF NOT EXIST php-installed.txt del /Q *.zip
29+
- IF NOT EXIST php-installed.txt copy /Y php.ini-development php.ini
30+
- IF NOT EXIST php-installed.txt echo max_execution_time=1200 >> php.ini
31+
- IF NOT EXIST php-installed.txt echo date.timezone="UTC" >> php.ini
32+
- IF NOT EXIST php-installed.txt echo extension_dir=ext >> php.ini
33+
- IF NOT EXIST php-installed.txt echo extension=php_openssl.dll >> php.ini
34+
- IF NOT EXIST php-installed.txt echo extension=php_mbstring.dll >> php.ini
35+
- IF NOT EXIST php-installed.txt appveyor DownloadFile https://getcomposer.org/composer.phar
36+
- IF NOT EXIST php-installed.txt echo @php %%~dp0composer.phar %%* > composer.bat
37+
- IF NOT EXIST php-installed.txt type nul >> php-installed.txt
38+
- cd c:\php-ethereum-token
39+
40+
test_script:
41+
- composer install
42+
- vendor/bin/phpunit.bat --coverage-text
43+

composer.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "kornrunner/ethereum-token",
3+
"description": "PHP Ethereum Token Utils",
4+
"keywords": ["ethereum", "offline", "transaction", "eth", "tx"],
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Boris Momcilovic",
9+
"homepage": "https://github.com/kornrunner/php-ethereum-token"
10+
}
11+
],
12+
"require": {
13+
"php": ">=7.2",
14+
"ext-bcmath": "*"
15+
},
16+
"autoload": {
17+
"psr-4": {
18+
"kornrunner\\": "src"
19+
}
20+
},
21+
"autoload-dev": {
22+
"psr-4": {
23+
"kornrunner\\": "test"
24+
}
25+
},
26+
"require-dev": {
27+
"phpunit/phpunit": "^8.2"
28+
}
29+
}

0 commit comments

Comments
 (0)