I am trying to but some Bep-20 tokens via code. My code submits the amount to be purchased in uint256 format which is Bep-20 standard (basically 18 decimals). However for a handful of tokens my code fails to buy them. When I digged into the problem I noticed that such tokens have uint8 format (see Tpt for example in the link below).
Does this mean such tokens are not Bep-20 standard and require me to customize my code for their own standard or am I missing something?
https://bscscan.com/token/0xECa41281c24451168a37211F0bc2b8645AF45092#readContract
Related
Thanks for taking the time to read my question!
I've previously built projects utilising the likes of coingecko, bscscan API etc... Which were perfect for the intended use-case, however now starting a new project I'm requiring informatiom which is proving problematic to obtain.
I'm trying to find a way to query a token address and obtain transaction information, such as how much BNB was spent in the transaction, and how many tokens were received in return.
With the tokens I'm trying to do this with, the majority of purchases are < 1BNB and as a result, BSCScan api returns 0 in the value key:value pair, as well as not providing the token quantities received.
While it would be nice to have access to token amounts received, it isn't absolutely necessary as I could produce this providing I had access to the amount spent on the transaction.
Outside of the commonly known APIs, is there a way to obtain this information?
I apologise if this is an obvious question, but with how transparent blockchain explorers are, I'm struggling to believe that there isn't some way to obtain this information, and struggling even further to figure out how to gain access to it.
So I have a token that has about 103 users. What I need to do is restrict the ability to sell those tokens to just myself the developer, so the other users can redeem their tokens for ETH or MATIC by sending to me. The alternative would be to just write a new smart contract, including this function and moving all users to the new platform. How would I write that new contract?
The first, you can't change code of deployed contract in Ethereum.
The second, look at ERC-20 and ERC-721 (NFT) standarts, its already have functionality you need.
I need to verify on my own domain/server the user which has connected his MetaMask wallet is the owner of a specific NFT in order to allow him special functions? Basically, I want to give the user access to an area that only the owner of this NFS would have.
My original NFT is sold in opensea but I can't use the opensea hidden-area option to just give the user a hidden password since the next owner (after reselling) and the old owner would have the same password and old owners could still access like this. But I need that only the current owner has access.
My user/visiter can already connect with MetaMask at my own domain and I get the public ETH address of the active account but since this is only javascript and my backend is PHP I can't just post the MetaMask info to my PHP backend since this would be easy to trick/hack.
How can I make sure the current connected MetaMask Account is the same as the NFT owner (which I know) and allow to access a URL only for this user?
My current state is that the user connects his MetaMask and I use opensea API to check who is currently the owner of the NFT. I can compare both eth addresses but the flaw in this is obviously that I use ajax to send the MetaMask public address to my backend which is only for testing since this is of course zero save!
Thank you in advance for any idea, help, tip I can get.
PS: My backend is PHP
After hours and days of researching, I found a solution that works for me.
Here are the needed steps.
Use the MetaMask API to let the user connect with your site. This is pretty easy and good explained in the MetaMask API.
Once you want to verify the MetaMask owner is the legit owner of an NFT you need first query OpenSea (or another place) the current owner of the NFT. In my case, I use the OpenSea API for my specific NFTs. Once you got the owner you are ready to verify.
On your site you need to ask the user to sign a custom message with MetaMask. There are different options to do that. More about this here: MetaMask Signing. I send for example a short text message with a unique code that I first created in my PHP Backend. Doing that I also save the code and custom message into my MySQL.
Once the user has signed you get the signing code which you can send back to your PHP backend via ajax etc. without a problem. Only the owner of the Account which you requested in the signing code is able to sign with the correct account.
Once you got the signing code in your PHP Backend you can use Fast Elliptic Curve Cryptography in PHP and php-ecrecover to check the code against the unique code you created before and the message the user signed. As a response, you get the Signer Account ETH Address and you are ready to compare. If the Signers ETH Address is the same as the NFT owner you are ready to go and you can consider the signer the owner of the NFT.
I believe this is safe to use but I am not an expert on that. In my case, this only authorize an NFT owner for a certain closed area in my community page and there are not really high risks involved but maybe somebody raises some security thoughts on that. However, I found that other NFT pages and even Opensea work similarly.
I hope this points someone in the right direction, I lost quite some time figuring this out because most solutions are Node.js etc. but not with PHP backends.
Is there a way to track your staking positions? All the Savings positions seem to be easy to reference through the API but it doesn't appear that it supports any of the staking functionality (lists, positions, history, purchasing, etc).
I've poured through the Savings section of the API documentation but it doesn't seem to support staking, nor is it in the wallet endpoints.
You can get your current staking positions by doing a signed GET request to this endpoint
/sapi/v1/staking/position
And get your staking history through this endpoint
/sapi/v1/staking/stakingRecord
For more information about these endpoints and what parameters should be included in the requests, see the official Binance API documentation
There's a part of me that thinks that if this is possible it kind of goes against the whole idea of a secure blockchain, but I just want to check and make sure.
Is it possible to create and deploy a smartcontract which creates a number of addresses, each with a pre-defined, initial balance of tokens? And if so, can these addresses then be made 'accessible' as a wallet for someone to use?
So, suppose I create a coin ABC, and it has a supply of 1.000.000.000 and I then create 10 addresses, each with, say, 50.000 ABC in them, with the remaining ABC tokens still in the 'genesis'/initial address - is that possible? Alternatively, can this kind of "pre-walleting" be done with a second contract after the token creation? And suppose now that I have said 50K ABC addresses, can they then be 'given' to users/made accessible?
Of course one can always create the coin and then do a bunch of transactions to do the above 'the old fashioned way' but I am curious if such a setup can be obtained in a faster/shortcut way.
This can not be achieved using the standard ERC20 token definition, what you want to do is very similar to an "Airdrop", in that case that can be achieved following these steps:
Create and deploy the ERC20 token.
Create a smart contract to handle the token distribution, this contract will contain the logic to handle or the distribution process.
Call the distribution contract and pass the array of addresses that
will receive the token.
The problem that i see with your proposed approach is that in order to give the addresses to the users you must provide them the private key, which means that they will not be in total control of their funds since you already know those keys, so i don't think this is a good decision.