To obtain a public key from a friendly text address using TonWeb's contract wallet module, you can use the create method to create an interface to the wallet's smart contract. You can specify the publicKey property to use a specific public key, or the address property to use a specific friendly text address.
Here's an example of creating a new interface to the wallet smart contract:
const nacl = TonWeb.utils.nacl;
const tonweb = new TonWeb();
const keyPair = nacl.sign.keyPair();
const wallet = tonweb.wallet.create({publicKey: keyPair.publicKey, wc: 0});
Once you have the wallet interface, you can use the getAddress method to obtain the friendly text address of the wallet. You can then use the get_public_key method to obtain the public key associated with the friendly text address. Here's an example:
const address = await wallet.getAddress();
const publicKey = await wallet.methods.get_public_key().call({address});
This code will obtain the friendly text address of the wallet and the associated public key. Note that the get_public_key
method is specific to the wallet smart contracts published in the TON repository and may not be available for other wallet contracts.