Search code examples
phpbinancebinance-smart-chain

How to create new Binance Smart Chain wallet, for every registered user and server side?


I'm starting by saying I'm new to developing on blockchains, but I have the need to add some features to my business platform.

What I'm trying to achieve now is to create a new Binance Smart Chain wallet address for all the users on my platform. Every user on my platform should have his own address, and address creation must be done on server side. The platform will take care of processing and managing incoming transactions on every wallet created. Platform implementation is done with Laravel framework.

I know there is Web3 to interact with the Smart Chain, but everything that is happening should not be on client side, and I'm not quite sure it could even work for what I'm trying to achieve.

Can I have some piece of information about where to start looking?


Solution

  • BSC uses the same algorithm to generate addresses from private keys as Ethereum. So you can use any Ethereum-compatible library, for example this one (so that you don't have to reinvent the wheel and calculate the keys from the elipctic curve).

    <?php
    require_once(__DIR__ . '/vendor/autoload.php');
    
    use kornrunner\Ethereum\Address;
    
    $privateKey = '33eb576d927573cff6ae50a9e09fc60b672a8dafdfbe3045c7f62955fc55ccb4';
    $address = new Address($privateKey);
    
    // 4e1c45599f667b4dc3604d69e43722d4ace6b770
    echo $address->get();