Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create EQA_gft901TRFYjWatkOSpFM0bB0EJuqGst9Akz5iYSdJYbj #58

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Re2906
Copy link

@Re2906 Re2906 commented Nov 7, 2024

`const { TonClient, abi } = require("@tonclient/core");
const { libNode } = require("@tonclient/lib-node");
TonClient.useBinaryLibrary(libNode);
const bip39 = require("bip39");
const hdkey = require("ethereumjs-wallet/hdkey");
const { toHex } = require("web3-utils");

const setupWallet = async () => {
const client = new TonClient({
network: {
endpoints: ["https://toncenter.com/api/v2/jsonRPC"]
}
});

const walletAddress = "EQA_gft901TRFYjWatkOSpFM0bB0EJuqGst9Akz5iYSdJYbj"; // Your wallet address
const seedPhrase = "kingdom hungry number apple plug borrow flame dose broken reject roof worry gallery gaze cost mind similar stool retire nephew unable prize involve slim"; // 24-word seed phrase

// Derive keys from seed phrase
const seed = bip39.mnemonicToSeedSync(seedPhrase);
const hdWallet = hdkey.fromMasterSeed(seed);
const wallet = hdWallet.derivePath(`m/44'/60'/0'/0/0`).getWallet();
const publicKey = toHex(wallet.getPublicKey());
const secretKey = toHex(wallet.getPrivateKey());

const callSet = {
    function_name: "setWalletType",
    input: {
        new_wallet_type: "wallet_v3R2"
    }
};

const signer = {
    type: "Keys",
    keys: {
        public: publicKey,
        secret: secretKey
    }
};

try {
    const { message } = await client.abi.encode_message({
        address: walletAddress,
        call_set: callSet,
        signer: signer,
        abi: {
            type: "Contract",
            value: {
                "ABI version": 2,
                header: ["time", "expire"],
                functions: [
                    {
                        name: "setWalletType",
                        inputs: [
                            { name: "new_wallet_type", type: "string" }
                        ],
                        outputs: []
                    }
                ],
                data: [],
                events: []
            }
        }
    });

    await client.processing.send_message({
        message,
        send_events: false
    });
    console.log("Wallet type successfully updated to v3R2");
} catch (error) {
    console.error("Error updating wallet type:", error);
}

};

setupWallet();

@Re2906

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant