javablockchainton

Why is the wallet address generated by ton4j library using 24 words different from the real address of the wallet created using ton blockchain apps?


public class App {   
    public static void main(String[] args) {

        try {
            Pair key = Mnemonic.toKeyPair(Arrays.asList("artwork", "people", "where", "dolphin", "assume", "develop", "polar",
            "link", "company", "boil", "over", "shed", "clump", "fall", "seed", "flag", "private", "opinion",
            "budget", "follow", "install", "skill", "agent", "garbage")); //Key pair of public key and private key generated using 24 words for the wallet

            TonLibService tonLibService; // Instance of TonlibService Class
            tonLibService = new TonLibService(true, key.getSecretKey());// Instance of TonlibService Class with a parameter of testNet:true and the key generated above

 public TonLibService(Boolean isTestNet, byte[] adminWalletSecret) throws InterruptedException { 
        // Initialize TonLib with configuration files
        tonlib = Tonlib.builder().testnet(isTestNet)
                .pathToTonlibSharedLib("lib/tonlibjson.dll")
                .pathToGlobalConfig("lib/testnet-global.config.json")
                .verbosityLevel(VerbosityLevel.FATAL)
                .ignoreCache(false)
                .build();


        // Initialize Admin Wallet with secret key
        adminWallet = WalletV4R2.builder()
                .tonlib(tonlib)
                .keyPair(TweetNaclFast.Signature.keyPair_fromSeed(adminWalletSecret))
                .build();


        System.out.println("Admin Wallet Address:" + adminWallet.getAddress());

The address I got from here differs from the address from a tonkeeper app wallet that has the 24 words above as a secret key. Why does it happen?


Solution

  • It is possible that you are using different versions of toncoin testnet. I have run your code and got the address "EQABkaXekKlGGtkzw0aB_KwGVtuQzSE-XLbXU5948s380s23" than i taped it in https://testnet.tonscan.org/address. And it tells: Contract Type wallet v4 r2. Tape there your tonkeeper address and you will see.

    I very interested in the subject can you write where you got this code, please. In the whole Internet your question is the only example of using ton4j.