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

Transfer 1 HNT with 0 HNT in wallet to another can be completed successfully #248

Open
idoor88 opened this issue Oct 21, 2021 · 1 comment

Comments

@idoor88
Copy link

idoor88 commented Oct 21, 2021

Hi all, I am curious why with the following code, I can execute the transaction of transferring 1 HNT to another with a transaction hash returned successfully even the wallet has 0 HNT, also is there a way to check the status of the transaction from an exchange or from Helium network?

async function make_transaction(){

  const client = new Client();
  
  console.log("make_transaction the client: ", client);
  
  // the transactions library needs to be configured
  // with the latest chain vars in order to calculate fees
  const vars = await client.vars.get();
  console.log("make_transaction the vars: ", vars);

  Transaction.config(vars);
  const entropy = await crypto.randomBytes(32); 
console.log("make_transaction entropy is: ", entropy);
let entropyStr = entropy.toString("hex");
console.log("make_transaction entropyStr: ", entropyStr); 
let bob = await Keypair.fromEntropy(entropy); 

  console.log("make_transaction bob is: ", bob);
  console.log("make_transaction the bob.address: ", bob.address);
  // initialize an address from a b58 string
  const alice = Address.fromB58('148d8KTRcKA5JKPekBcKFd4KfvprvFRpjGtivhtmRmnZ8MFYnP3');
  console.log("make_transaction the alice: ", alice);
  //let mnemonic = alice.mnemonic;
  //console.log("make_transaction the mnemonic: ", mnemonic);
  // get the speculative nonce for the keypair
  console.log("make_transaction the bob.address.b58: ", bob.address.b58);
 // let publicKey = bob.publicKey;
  //console.log("make_transaction the publicKey: ", publicKey);
  //let publicKeyString = Base64.fromUint8Array(publicKey);
  //console.log("make_transaction publicKeyString: ", publicKeyString);
 // let publicKeyBack = Base64.toUint8Array(publicKeyString);
  //console.log("make_transaction publicKeyBack: ", publicKeyBack);
  //const account = await client.accounts.get(bob.address.b58);

  //console.log("make_transaction the balance.floatBalance: ", account.balance.floatBalance); 

  //console.log("make_transaction the account: ", account);
  // construct a payment txn
  const paymentTxn = new PaymentV1({
      payer: bob.address,
      payee: alice,
      amount: 1,
      nonce: alice.speculativeNonce + 1,
  });
  
  console.log("nonce is: ", paymentTxn);
  console.log('transaction fee is:', paymentTxn.fee);
  
  const signedPaymentTxn = await paymentTxn.sign({ payer: bob });
  
  console.log("make_transaction the serialized transaction: ", signedPaymentTxn.toString());
  let txHash = await client.transactions.submit(signedPaymentTxn.toString())
  console.log("make_transaction the transaction hash: ", txHash);

}

Thanks in advance!

@KnightAR
Copy link

KnightAR commented Jan 7, 2022

If you get the HASH that it returns and pull this url https://api.helium.io/v1/pending_transactions/:hash it'll tell you the status. For all the previous pending transactions, you can do https://api.helium.io/v1/accounts/148d8KTRcKA5JKPekBcKFd4KfvprvFRpjGtivhtmRmnZ8MFYnP3/pending_transactions and you'll notice that the 1 HNT payment failed.

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