What I want to achieve is to create a UI(e-Commerce user interface) to allow the user to enter the amount.In this case, the amount would be in USD; from the back-end, it will calculate and convert the USD amount to the corresponding gas value then send it to the Smart Contract. Has anyone experienced that?
Related
I am looking to convert gas fee info from this api end point: into dollars (calculating taxes).
The endpoint gives 'gas', 'gasPrice' and 'gasUsed' values that I'm sure would be enough, but I can't quite work it out.
You can calculate the price in dollars using the following formula:
usdPrice = gasUsed * gasPrice * ethToUsd
You can take the first two parameters (gasUsed and gasPrice) from etherscan. To get the current conversion rate between ETH and USD (ethToUsd) you need to query some exchange API, e.g., https://min-api.cryptocompare.com/.
I am building a scraper to get all Swap data from Uniswap using web3js.
So far I subscribe to the log and filter topics by Swap() event.
then I decode the data and get amount0In, amount1In, amount0Out, amount1Out.
My problem is in the swapExactETHForTokensSupportingFeeOnTransferTokens() function.
Normally a swap has token0 in and token1 out, but this function gives me values for 3 of the 4 and I can not seem to understand how to handle that. eventually what I want is to know what they spend, what they got and what I need to update the new reserves of that pair.
If someone has the understanding of the Uniswap RouterV2 contract swap functions, I would like to get some pointers on how to handle the data to get my calculations right.
I found the solution here ethereum.stackexchange Anyone with the same question gets a very detailed answer there.
some contracts actually transfers to recipient specified amount of tokens minus 10% (5% tax fee and 5% liquidity fee) 208940457743532637 - 10% = 188046411969179375 and emits Transfer event. Then, PancakePair _swap function emits Swap event with base value of Amount0Out 208940457743532637
Amount0In is greater than zero because the token contract returns part of tokens as a liquidity pair on Pancake Swap.
If I mint a collection of n items on my own address (via smart contract) , it'll be publicly visible on my account under the collected / created section like this .
The problem is that , in order to complete the listing I must manually set the price of each NFT individually. Obviously this is not practical , since I cannot set the price of every NFT one by one manually , not to mention that every time a listing is completed (by setting the price) , gas fee has to be paid.
Therefore I want to be able to achieve setting the price programatically such that after minting , the collection looks like this.
I tried to approach this problem via OpenSea-Creatures SDK (which uses Truffle) , but Im not sure if their sales-contract can achieve this. (I couldn't get it to run either).
I know this question is very generic but I've been looking for a solution for a while and I haven't found anything helpful.
Any guidance in the right direction would be of tremendous help!
I also faced the same issue when i was creating a large NFT collections of over 3,000. The best solution i will recommend is Creating a Custom Sale Contract.
The downside of the simple item sale is that you'll need pre-mint the items that you want to sell (as opposed to minting them on the fly when they're purchased). This can make it difficult to sell many items to a broad user base. Additionally, with the simple item sale method, it's difficult to create custom logic for the sale of your items (like packs of random items, randomized stats for the items that are minted, etc.). If you want any of these features, the Factory contract is for you!
In order to mint items only when they're purchased, OpenSea provides a Factory interface that you can use to define how your items will be minted. You then use OpenSea to create custom "orders" that call your minting function. Here's a look at the main mint method of the Factory contract.
Selling many of one option
While the OpenSea UI lets you sell one Factory item at a time, in many circumstances, you may want to sell off a large number of items to your initial users: for example, 100 swords or 100 packs of cards. For this, we recommend using the SDK to instantly create sales with a given supply. As an example, suppose you wanted to put 100 items up for sale in your crowdsale for a fixed price, expiring tomorrow. You could do the following:
// Expire these auctions one day from now. Omit `expirationTime` or set to 0 to never expire:
const expirationTime = (Date.now() / 1000 + 60 * 60 * 24)
const sellOrders = await seaport.createFactorySellOrders({
assetId: <ASSET_OPTION_ID>,
factoryAddress: <FACTORY_CONTRACT_ADDRESS>,
accountAddress,
startAmount,
expirationTime,
numberOfOrders: 100 // Will create 100 sell orders in parallel batches to speed things up
})
Check this link to see how to create a factory contract
https://docs.opensea.io/docs/2-custom-item-sale-contract
#Ngyfsoau
Background:
I am working on making nodejs function for payment using stripe.
My clients would have their own reward point, which can turn into cash dollar for payment
Current Design
Customer Table(mySQL)
-id: string(primary key)
-rewardPoints: int
Therefore I am working on 2 api seperately.
/transaction/debit-points
-this api is used to debit the reward point of clients when they want to turn it into cash dollar(debit the rewardPoints in Customer table)
/payment
-this api will use stripe api to handle some credit card payment etc
Example
Let's say 100 reward points can turn into $1 cash dollar
Customer A is going to settle payment which is $200.
Customer A have 1000 reward points and want to turn all of it into cash dollar in this payment.
At first, I will use /transaction/debit-points to debit all 1000 reward points for the customer, and then use /payment to settle the payment.
1. /transaction/debit-points
2. /payment (run if /transaction/debit-points is successful)
If /payment fails, I want to reverse the effect of /transaction/debit-points, is it possible to do it in nodejs?
Or is there any better way?
I am trying to understand the concept of cellid (http://www.opencellid.org/api)
As per that, if we send a request
http://www.opencellid.org/cell/get?key=myapikey&mnc=1&mcc=2&lac=200&cellid=234
it will respond with the latitude and longitude.
I was wondering if this can be used from within a google map application for tracking a user or it needs to be used from within a mobile device?
If it can be used from within a web app, what parameters should it use for
mcc: mobile country code (decimal)
mnc: mobile network code (decimal)
lac: locale area code (decimal)
cellid: value of the cell id
E.g., will it work if we know the cell number of the person(e.g., 281 222 6700)
The request is just a lookup in the opencellid database.
It doesn't matter where the information is coming from.
If you know the MMC, MNC, LAC and CellID of a user/mobile device,
the request will return latitude and longitude if the cellID has been found in the DB.
There is no additional information transfered by using the request from within a J2ME app.
MCC+MNC+LAC+CELLID should be a unique identifier of a cell. (afaik those values can change over time,
but they still should be unique.)
More often than not, knowing just the LAC and CellID is sufficient.
However, you can't use this to track based on a number, only by cell tower parameters. Number tracking is a whole different ball game with VRL & HRL lookups which are hard to come by, very expensive ($100+ per lookup) and sometimes even illegal.
Google Maps also uses cell ID lookups to approximate the user's location before GPS kicks in (the translucent circle around a dot is actually data from Cell IDs).
That being said, opencellid has very minimal coverage and little or no updates to the project. Check out some paid players who offer wider coverages:
LocationAPI
Combian