I reply to all queries on the forums and via email, once per day, Monday to Friday (not weekends).

If you are new here, please see some information on how to ask for support. Thank you!

Reply To: Use of the plugin’s front end without the need for JavaScript

dashed-slug.net Forums General discussion Use of the plugin’s front end without the need for JavaScript Reply To: Use of the plugin’s front end without the need for JavaScript

#13608
alexg
Keymaster

Hello,

The code you provided does not work because you are creating a class Wallets that does not exist. There is a DSWallets\Wallet class that contains an adapter object of DSWallets\Wallet_Adapter class. The wallet adapter is an object that holds the connection information to the wallet as well as the code to communicate with the wallet. You can call get_new_address on the wallet adapter to get a new address.

Once you have a $currency object, here’s how to generate a new address:

$new_address = $currency->wallet->adapter->get_new_address( $currency );

(It’s necessary to pass the currency into the method because there are wallets with multiple currencies e.g. CoinPayments wallet)

It’s best to wrap this in a try..catch, because if there is any problem with communication with the wallet, this can throw.

So, to put it all together:

try {

$new_address = $currency->wallet->adapter->get_new_address( $currency );

} catch ( \Exception $e ) {
error_log( “Could not generate a new address for $currency because: ” . $e.getMessage() );
}

In general, the UIs that require JavaScript, communicate with the plugin via its RESTful API, which is here and documented here.

If you check out the code for the various API endpoints, you can see example code for the basic operations.

Hope this helps.

Please let me know if you have any more questions. I want to answer all of them and help you with your project.

with regards