Skip to content

Commit

Permalink
composer and example config
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex committed Mar 12, 2022
1 parent abd4150 commit bb21bca
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 27 deletions.
File renamed without changes.
6 changes: 1 addition & 5 deletions Core/sweb3.class.php → Core/SWeb3.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@
* @license MIT
*/

namespace SWeb3;

include_once("../vendor/autoload.php");
include_once("abi.class.php");
include_once("sweb3_utils.class.php");
namespace SWeb3;

use SWeb3\Utils;
use kornrunner\Ethereum\Transaction;
Expand Down
3 changes: 1 addition & 2 deletions Core/sweb3_contract.class.php → Core/SWeb3_Contract.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
*/

namespace SWeb3;

include_once("sweb3.class.php");


use SWeb3\Utils;
use SWeb3\SWeb3;
Expand Down
File renamed without changes.
8 changes: 5 additions & 3 deletions Example/example.call.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

/**
* This file is part of simple-web3-php package.
*
Expand All @@ -9,12 +8,15 @@
* @license MIT
*/

namespace SWeb3;

ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');

include_once("../Core/sweb3_contract.class.php");
include_once("../vendor/autoload.php");
include_once("example.config.php");


use stdClass;
use SWeb3\SWeb3;
use SWeb3\Utils;
use SWeb3\SWeb3_Contract;
Expand Down
1 change: 0 additions & 1 deletion Example/example.config.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

/**
* This file is part of simple-web3-php package.
*
Expand Down
9 changes: 5 additions & 4 deletions Example/example.send.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
* @author Alex Cabrera
* @license MIT
*/
namespace SWeb3;

ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');

include_once("../Core/sweb3.class.php");
include_once("../Core/sweb3_contract.class.php");
include_once("../vendor/autoload.php");
include_once("example.config.php");


use stdClass;
use SWeb3\SWeb3;
use SWeb3\Utils;
use SWeb3\SWeb3_Contract;
Expand Down Expand Up @@ -96,7 +97,7 @@ function Contract_Set_public_uint()
//get nonce gives you the "desired next number" (makes a query to the provider), but you can setup more complex & efficient nonce handling ... at your own risk ;)
$extra_data = ['nonce' => $sweb3->getNonce(SWP_ADDRESS)];

//$contract->send always populates: gasPrice, gasPrice, IF AND ONLY IF they are not already defined in $extra_data
//$contract->send always populates: gasPrice, gasLimit, IF AND ONLY IF they are not already defined in $extra_data
//$contract->send always populates: to (contract address), data (ABI encoded $sendData), these can NOT be defined from outside
$result = $contract->send('Set_public_uint', time(), $extra_data);

Expand Down
21 changes: 21 additions & 0 deletions LICENCE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) Kuan-Cheng,Lai

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# simple-web3-php

[![PHP](https://github.com/drlecks/Simple-Web3-Php/actions/workflows/php.yml/badge.svg)](https://github.com/drlecks/Simple-Web3-Php/actions/workflows/php.yml)
[![Build Status](https://travis-ci.org/drlecks/Simple-Web3-Php.svg?branch=master)](https://travis-ci.org/drlecks/simple-web3-php)
[![codecov](https://codecov.io/gh/drlecks/Simple-Web3-Php/branch/master/graph/badge.svg)](https://codecov.io/gh/drlecks/Simple-Web3-Php)
[![Join the chat at https://gitter.im/drlecks/Simple-Web3-Php](https://img.shields.io/badge/gitter-join%20chat-brightgreen.svg)](https://gitter.im/drlecks/Simple-Web3-Php)

[![Join the chat at https://gitter.im/drlecks/Simple-Web3-Php](https://img.shields.io/badge/gitter-join%20chat-brightgreen.svg)](https://gitter.im/Simple-Web3-Php/community)
[![Licensed under the MIT License](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/drlecks/Simple-Web3-Php/blob/master/LICENSE)


Expand Down Expand Up @@ -34,7 +31,7 @@ composer require drlecks/simple-web3-php dev-master
Or you can add this line in composer.json

```
"drlecks/simple-web3-php": "dev-master"
"drlecks/simple-web3-php": "~1"
```


Expand Down Expand Up @@ -144,7 +141,7 @@ define('SWP_Contract_ABI', $SWP_Contract_ABI);
To enable transaction sending & signing, enter a valid pair of address and private key. Please take this advises before continuing:
- The address must be active on the ropsten network and have some ether available to send the transactions.
- Double check that you are using a test endpoint, otherwise you will be spending real eth to send the transactions
- Be sure to keep you private key secret!
- Be sure to keep your private key secret!

```php
//SIGNING
Expand Down
18 changes: 13 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
{
"name": "drlecks/simple-web3-php",
"description": "Web3 library in PHP.",
"description": "Web3 library in PHP",
"keywords": ["ethereum", "transaction", "jsonRPC", "eth", "signed transaction", "php", "web3", "contract"],
"type": "library",
"license": "MIT",

"authors": [
{
"name": "drlecks",
"email": "[email protected]"
"email": "[email protected]",
"homepage": "https://github.com/drlecks/Simple-Web3-Php"
}
],
"require-dev": {
"phpunit/phpunit": "~7|~8.0"
},

"require": {
"kornrunner/ethereum-offline-raw-tx": "^0.4.0",
"kornrunner/keccak": "~1",
"phpseclib/phpseclib": "~2.0.30"
},

"autoload": {
"psr-4": {
"SWeb3\\": "Core/"
}
}

}

0 comments on commit bb21bca

Please sign in to comment.