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

Address.toString() is not working as intended #284

Open
camheras opened this issue Oct 18, 2024 · 2 comments
Open

Address.toString() is not working as intended #284

camheras opened this issue Oct 18, 2024 · 2 comments

Comments

@camheras
Copy link

camheras commented Oct 18, 2024

The isTestOnly and isUrlSafe parameters are not editing the address in any way.

Should change the prefix from to 0Q...

Return kQ...

Initial code :

async createWallet() {
    const keyPair = TonWeb.utils.nacl.sign.keyPair()

    const tonweb = new TonWeb(
      new TonWeb.HttpProvider("https://testnet.toncenter.com/api/v2/jsonRPC", {
        apiKey: process.env.TON_APIK,
      }),
    )
    const publicKey = keyPair.publicKey
    const privateKey = keyPair.secretKey

    const WalletClass = TonWeb.Wallets.all.v3R2
    const wallet = new WalletClass(tonweb.provider, {
      publicKey: publicKey,
    })

    const walletAddress = await wallet.getAddress()

    const address = walletAddress.toString(true, true, true, true)
    return { address, publicKey, privateKey }
  }

kQDfl16YteDtIIAMn8nnVcSEJmPw5Gz6z7l_LoB4M-Llt8uO

Tried this :

walletAddress.isTestOnly = true
  walletAddress.isBounceable = true
  walletAddress.isUrlSafe = true
  walletAddress.isUserFriendly = true

  const address = walletAddress.toString(true, true, true, true)

Here the isTestOnly is not working and isUrlSafe are not doing anything

@khalilmosavi
Copy link

async createWallet() {
const keyPair = TonWeb.utils.nacl.sign.keyPair()

const tonweb = new TonWeb(
  new TonWeb.HttpProvider("https://testnet.toncenter.com/api/v2/jsonRPC", {
    apiKey: process.env.TON_APIK,
  }),
)
const publicKey = keyPair.publicKey
const privateKey = keyPair.secretKey

const WalletClass = TonWeb.Wallets.all.v3R2
const wallet = new WalletClass(tonweb.provider, {
  publicKey: publicKey,
})

const walletAddress = await wallet.getAddress()

const address = walletAddress.toString(true, true, true, true)
return { address, publicKey, privateKey }

}

@khalilmosavi
Copy link

walletAddress.isTestOnly = true
walletAddress.isBounceable = true
walletAddress.isUrlSafe = true
walletAddress.isUserFriendly = true

const address = walletAddress.toString(true, true, true, true)

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

No branches or pull requests

2 participants