Git Product home page Git Product logo

waveskit's Introduction

WavesKit

packagist php-v GitHub codacy license

WavesKit is an all-in-one Waves Platform development kit for the PHP language.

  • All you need to work with Waves in a single class
  • Really easy to use
  • Best practices for all
  • Advanced features for pros

Basic usage

$wk = new WavesKit( 'T' );
$wk->setSeed( 'manage manual recall harvest series desert melt police rose hollow moral pledge kitten position add' );
$tx = $wk->txBroadcast( $wk->txSign( $wk->txTransfer( 'test', 1 ) ) );
$tx = $wk->ensure( $tx );

Documentaion

  • WavesKit documention: WavesKit.md
  • Consider to learn self tests: selftest.php
  • Self tests contain tests of all transactions which can easily be used as examples

Requirements

Will be installed automatically through composer install:

Recommended

Installation

Require through Composer: composer require deemru/waveskit

{
    "require": {
        "deemru/waveskit": "*"
    }
}

waveskit's People

Contributors

deemru avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

waveskit's Issues

Failed to parse json message on leasing function

Error message:

ERROR: https://testnode2.wavesnodes.com (1) (failed to parse json message)

Could you help me please? Here is my code at the file leasing.php:

<?php
/* Thanks to Deemru */

require __DIR__ . '/vendor/autoload.php';
use deemru\WavesKit;

$wk = new WavesKit('T');
$wk->setSeed('my seed dream embrace caution accuse panic uncover chicken');
$wallet_sender = '3MvmV4LrVt8YE2BdgGZ5viMTECnizWUnHz6';
$balance = $wk->balance($wallet_sender);
$balance = $balance[0]['balance'];
$leaseAmount = (int)($balance / 4);
$wallet_leasing = '3N8ztdAGAdu9QAV5aJfvkzKfVryt1fTK7hD';
$confirmations = 1;
$sleep = 10;

$tx = $wk->txLease($wallet_leasing, $leaseAmount);
$tx = $wk->txSign($tx);

$leaseId = $tx['id'];
$trx = $wk->txTransfer($wk->getAddress($wallet_leasing), $leaseAmount);
$tx = $wk->txBroadcast($tx);
$tx = $wk->ensure($tx, $confirmations, $sleep);

But when I execute from console it's work and successful:

php leasing.php                                                                         634  09:50:22 
2019.05.18 09:50:39    INFO: (9ff8PazsyoVpikzkuMAWcz2MyaKArjxQ6T6cfKeKWUWP) unconfirmed (1)
2019.05.18 09:50:49 SUCCESS: (9ff8PazsyoVpikzkuMAWcz2MyaKArjxQ6T6cfKeKWUWP) confirmed (2)
2019.05.18 09:50:50    INFO: (9ff8PazsyoVpikzkuMAWcz2MyaKArjxQ6T6cfKeKWUWP) 0/1 confirmations (1)
2019.05.18 09:51:00    INFO: (9ff8PazsyoVpikzkuMAWcz2MyaKArjxQ6T6cfKeKWUWP) 0/1 confirmations (2)
2019.05.18 09:51:11    INFO: (9ff8PazsyoVpikzkuMAWcz2MyaKArjxQ6T6cfKeKWUWP) 0/1 confirmations (3)
2019.05.18 09:51:21    INFO: (9ff8PazsyoVpikzkuMAWcz2MyaKArjxQ6T6cfKeKWUWP) 0/1 confirmations (4)
2019.05.18 09:51:32    INFO: (9ff8PazsyoVpikzkuMAWcz2MyaKArjxQ6T6cfKeKWUWP) 0/1 confirmations (5)
2019.05.18 09:51:42    INFO: (9ff8PazsyoVpikzkuMAWcz2MyaKArjxQ6T6cfKeKWUWP) 0/1 confirmations (6)
2019.05.18 09:51:52 SUCCESS: (9ff8PazsyoVpikzkuMAWcz2MyaKArjxQ6T6cfKeKWUWP) reached 1 confirmations
Array
(
    [senderPublicKey] => 7G9p5z5YuqVMZT41keghiSsCNYxeL5tUu66pwdy9T1a1
    [amount] => 498330371
    [fee] => 100000
    [type] => 8
    [version] => 2
    [sender] => 3MvmV4LrVt8YE2BdgGZ5viMTECnizWUnHz6
    [feeAssetId] => 
    [proofs] => Array
        (
            [0] => 3UEJFU9VhvgFKbKoeSqR7j2H3Pb1YpVjB7CFe2HcqimDfckdK4r1yLYYjYf46wLdo8konkZq25t3HcpNFvvnyF3e
        )

    [recipient] => 3N8ztdAGAdu9QAV5aJfvkzKfVryt1fTK7hD
    [id] => 9ff8PazsyoVpikzkuMAWcz2MyaKArjxQ6T6cfKeKWUWP
    [timestamp] => 1558147837130
    [status] => active
    [height] => 566814
    [confirmations] => 1
)

Thank you before for your help.

Request: Add method to get Data by providing a regexp

Proposal to add a method to retrieve Data by specifying a regexp. The engine should extract all keys satisfying a certain regexp.

There could be a performance problem if the regexp expression extract too many items, maybe a limit can be added.

Alternatively please evaluate an API to extract all data from an address so it can be processed in an array

txInvokeScript return false

Hi, I'm using the latest version of the WavesKit, txInvokeScript function in particular.
$wk = new WavesKit( 'T' ); // 'T' for testnet
$wk->setSeed( $user_bc_seed );
$options = array(
"fee" => 900000
);
$args = [
$titolo,
$arrayData
];
$tx = $wk->txSign( $tx );
$tx = $wk->txInvokeScript( $user_bc_address, "addItem", $args, null, $options);
$tx = $wk->txBroadcast( $tx );
$response = json_encode($tx);

$tx before txBroadcast look like
{
"type":16,
"version":1,
"sender":"3MsJAaF5QnFSPWt1FbTYg2rZEYGE89zL9xm",
"senderPublicKey":"AuwNnJne9DDzFJMVzgSTvELEvJKcS6sAwa1pYot7NSZc",
"timestamp":1565976714741,
"dApp":"3MsJAaF5QnFSPWt1FbTYg2rZEYGE89zL9xm",
"call":{
"function":"addItem",
"args":[
{"type":"string","value":"eee"},
{"type":"string","value":"{"titolo":"eee","descrizione":"ytutyuty","allegato":""}"}]
},
"payment":[],
"fee":500000,
"chainId":84
}

The function addItem is a script deployed into dApp and works if called from Waves IDE.
From my php code, I get FALSE as answer but I can't understand what happens.

Someone can help me? Thank in advance

Get Address

How can I get an address using the phrase seed?

And how can I get the private key using the seed phrase?

Update Asset Info Transaction

Hi, I would like to use the "Update Asset Info Transaction", but when I've tried to compile an asset script with a restriction on it, I've got an error even if the script was correct in waves-ide.com.
Basically I think that it depends on version: is it possible to have this transaction using your library? In the documentation I have not seen this kind of functionality, but... better ask!

Thanks in advance.

how to convert the waves timestamp

I am still not get the date format for waves timestamp more than 10 digits, something like this: 1561174381555 as I know In PHP date format just 10 digits. I have try to use:
date('Y-m-d H:i:s T') but the output: 51441-08-25 05:25:55 WIB
but if I substr 3 digit from behind 1561174381(555) the output: 2019-06-22 10:33:01 WIB
what is the actual date format for waves timestamp?
Thank you.

Problem with txTransfer

Hello @deemru I have an issue when implemented txTransfer using bot. When I use the entire parameter no issue found. But when I devide the two parameters ($recipient and $amount) I get an error:

ERROR: https://nodes.wavesplatform.com (1) (failed to parse json message)

notes: $cmd_second = recipient and $cmd_third = amount are the 2 parameters input by user on Telegram bot
/send 3P3gpCLtTJb63Ac94LVoUmFLMQwcyjKbfRW 100

Here is my code:

$wk = new WavesKit('W');
$wk->setPrivateKey('Csv3gBlAblablalallAlbalal');
$assetId = '42LxnagWNNeEvHNk5zhWg6WPPpgYoyxjbSAA8m28MTQb';
$feeAssetId = '8RwwkZJ373Nm6fJCgV2Lefe6FeWawUY2APujcsauUNMR';

$options = ['fee' => 1, 'feeAssetId' => $feeAssetId];
$tx = $wk->txTransfer($cmd_second, $cmd_third, $assetId, $options);
$tx = $wk->txSign($tx);
$tx = $wk->txBroadcast($tx);

if I wrote directly the parameter no error appear:

$tx = $wk->txTransfer(3P3gpCLtTJb63Ac94LVoUmFLMQwcyjKbfRW, 100, $assetId, $options);

Please help me to solve this issue. Thank you.

composer install

I installed with composer require deemru/waveskit
And what I get you can see here
I think you need to update package

txIssue

Hi, I'm trying to use txIssue method in the following way
$wk = new WavesKit( 'T' );
$wk->setSeed( $user_bc_seed );
$confirmations = 1;
$sleep = 10;
$tokenName = $user_bc_alias . '_' . strval($order_id);
$tokenDescription = 'NFT per ' . $titolo;
$tx = $wk->txIssue( $tokenName, $tokenDescription, 1, 0, false );
$tx = $wk->txSign( $tx );
$tx = $wk->txBroadcast( $tx );
$tx = $wk->ensure( $tx, $confirmations, $sleep );
$tokenId = $tx['id'];

the trace for $tx is
{"type":3,"version":2,"sender":"3MsJAaF5QnFSPWt1FbTYg2rZEYGE89zL9xm","senderPublicKey":"AuwNnJne9DDzFJMVzgSTvELEvJKcS6sAwa1pYot7NSZc","fee":100000000,"timestamp":1566380070986,"name":"INARTE_PippoPippo_80557","description":"NFT per Prova LUI","quantity":1,"decimals":0,"reissuable":false}

but I get no answer, neither FALSE nor array.
What can I try?

Thanks in advance

Cannot sign a message

I don't know if I am making some mistakes...

Testing with TESTNET address: 3Mzp4yJ3CGWTX5Wy1f67aLaTvxdCW2ZdyPj, private key: BG3qtTABZnx74zZqMkFs5Q8tusKaCXDefmzLAswK9AzT

[...]
 
        $wk = new deemru\WavesKit( 'T' );        
        $signed=$wk->sign('a', 'BG3qtTABZnx74zZqMkFs5Q8tusKaCXDefmzLAswK9AzT');
        log_message('Info', $signed)

Returns false.

Cannot declare class kornrunner\Keccak, because the name is already in use

Добрый день!
У меня уже подключена support/Keccak.php отдельным пакетом. Вы не сменили namespace в переопределенном классе Keccak.php и теперь возникают ошибкa Cannot declare class kornrunner\Keccak, because the name is already in use

Order issue returning false.

Thank you for sharing this package.

I can seem to get the txOrder to work.

I most likely have got the sequence for transmitting an order incorrect. Can you point me in the right direction.

`require DIR . '/../vendor/autoload.php';
use deemru\WavesKit;

$wk = new WavesKit();
$wk->setPrivatekey('REDACTED_BUT_CORRECT');
$order = $wk->txOrder ('Ft8X1v1LTa1ABafufpaCWyVj8KkaxUWE6xBhW6sNFJck', 'BiHyoWW3M3AjbU1pE5t1hNrJG5KtmtFvD43UDpqRyyzh', false, 25, 100, 10 * 60 );
$signed = $wk->txSign($order);
$return = $wk->txOrderBroadcast($signed);
var_dump($signed);
var_dump($return);`

Here is the output:

array(13) { ["version"]=> int(2) ["sender"]=> string(35) "3PGmcbDUGaTtxMSv1HsCmVSbAQkj7CagQ3a" ["senderPublicKey"]=> string(43) "8VAwR7Tpd9h189YGJQHJwWFxCGU31qvuZCAbSTY45qb" ["matcherPublicKey"]=> string(44) "7kPFrHDiGw1rCm7LPszuECwWYL3dMf6iMifLRDJQZMzy" ["assetPair"]=> array(2) { ["amountAsset"]=> string(44) "Ft8X1v1LTa1ABafufpaCWyVj8KkaxUWE6xBhW6sNFJck" ["priceAsset"]=> string(44) "BiHyoWW3M3AjbU1pE5t1hNrJG5KtmtFvD43UDpqRyyzh" } ["orderType"]=> string(3) "buy" ["amount"]=> int(25) ["price"]=> int(100) ["matcherFee"]=> int(300000) ["timestamp"]=> int(1559810103668) ["expiration"]=> int(1559810104268) ["id"]=> string(44) "C3kQxnhnbzwJwV5bLjbHMGAnUTP1hdoVhgx7SXASnReA" ["proofs"]=> array(1) { [0]=> string(87) "Nfy7Fqt2B8XiuhHhE4zs8CqhscS3C75vmpkEo4yeMxHru2vdjY5AAMHEXkrpgc3iZh6NfnPwtCQXhe3Wy1Bpbhr" } } bool(false))

Please help how to convert price in Waves with PHP

Hello sir..
I still confuse how to convert the prices on Waves with PHP. I have use the code like something below:

function convert_price($n)
{
    // first strip any formatting;
    $n = (0 + str_replace(",", "", $n));

    // is this a number?
    if (!is_numeric($n)) return false;
    // now filter it;
    if ($n > 10000000000000) return ($n / pow(10, 21)); //13/21
    elseif ($n > 1000000000000) return ($n / pow(10, 14)); //12/21
    elseif ($n > 100000000000) return ($n / pow(10, 14)); //11/21
    elseif ($n > 10000000000) return ($n / pow(10, 14)); //10/14
    elseif ($n > 1000000000) return ($n / pow(10, 13)); //9/13
    elseif ($n > 100000000) return ($n / pow(10, 13)); //8/13
    elseif ($n > 10000000) return ($n / pow(10, 8)); //7/13
    elseif ($n > 1000000) return ($n / pow(10, 8)); //6/10
    elseif ($n > 100000) return ($n / pow(10, 8)); //5/8
    elseif ($n > 10000) return ($n / pow(10, 8)); //4/8
    elseif ($n > 1000) return ($n / pow(10, 8)); //3/8
    elseif ($n > 100) return ($n / pow(10, 8)); //2/8
    elseif ($n > 10) return ($n / pow(10, 8)); //1/8
    elseif ($n > 0) return ($n / pow(10, 8)); //0/8

    return number_format($n, 8, ',', '.');
}```

but sometimes the formula above works, sometimes the digits numbers of price changes. I found the formula at the matcher.wavesplatform.com something like this:
```10^(8+Asset1desimal - Asset2desimal)```
and another formula with for Python.
But how to implement it to PHP? Thanks before if you kindly to make any function for this issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.