NEAR Marketplace - How should I charge the transaction fee on each sales? - nearprotocol

We're building a marketplace in NEAR. We have two smart contracts for token and marketplace. Same as NEAR example.
In our platform, we have successfully implemented below features:
Token mint (used contract method: nft_mint)
Token listing for sale in marketplace (used contract methods: storage_deposit nft_approve)
Token purchase (used contract method: offer)
Everything is working fine.
Now, we want to charge the transaction fee (2.5%) on each sales for our marketplace.
--
I did one mint and buy test with Paras Marketplace to observe the royalty and transaction fee distribution. Here is the test details:
With seller.near account, I minted an NFT in Paras Marketplace. And added 3% royalty. And listed it #1 Ⓝ for sale.
With buyer.near account, bought it with another account.
NFT Details:
Name : My Non-fungible token #1
Listed Price : 1 Ⓝ
Royalty : 3%
Sale Breakdown:
Receive (Seller) : 0.95 Ⓝ
Royalty (Creator) : 0.03 Ⓝ
Fee (Paras) : 0.02 Ⓝ
Before purchase - Account Balance
buyer.near : 50.03995 Ⓝ
seller.near : 4.896 Ⓝ
After purchase (1st sale after minted) - Account Balance
buyer.near : 49.03388 Ⓝ | Difference : -1.00607 Ⓝ
seller.near : 5.82587 Ⓝ | Difference : +0.92987 Ⓝ
# NFT Create Transaction
This is nft_create_series transaction. Where Paras is sending "transaction_fee": "200" to charge 2% service fee on each sale:
# NFT Buy Transaction
This is buy transaction. Where Paras charged 2% service fee:
Question:
We want to charge 2.5% service fee on each sales.
We want to implement "transaction_fee": "250" object in our marketplace contract.
How to do the same with our marketplace?

There are several ways that you can go about doing this. The two that I would recommend are the following (I saw you were following along with the zero to hero tutorial):
Option A (simplest) - store your account in the perpetual royalties object for the token when it is minted.
This is the easiest to implement as you don't need to change anything in your contracts and you simply need to alter what is passed into the royalties object on mint.
This requires that you have control over the NFT contract.
This allows you to receive royalties on whatever marketplace the token is sold on since the royalties are stored on the token level in the NFT contract.
This allows you to specify which account should receive the royalties instead of forcing the marketplace contract to store the funds.
Option B - before calling nft_transfer_payout in your marketplace contract, subtract 2.5% from the price object. This will result in your marketplace contract keeping the 2.5% and paying out the remaining 97.5% to the respective accounts.
With this approach, since many accounts are paying for storage, your contract has funds that aren't all withdraw-able by you. You should keep a tally on how much $NEAR you've received so that you can withdraw that amount and not accidentally withdraw too many funds that may have "belonged" to someone else via storage deposits.

Related

why no rewards are appeared in solana stake account testnet?

I have two stake accounts in the Testnet validator none of them showing any rewards is something wrong with the configuration
Wallet: https://explorer.solana.com/address/EjGaPZ59sycMm46VpbukVY9PnwSdPYCfeQnbRLaZaD7m?cluster=testnet
Identity : https://explorer.solana.com/address/GfudXfSxpvSBvkyNG7K1CdFhntZw3ASvBeCiTSRV5nzr?cluster=testnet
Vote: https://explorer.solana.com/address/7R5of8HZreWPjURAMupJuik7vx5SAGUghpwU648bWYnt?cluster=testnet
Stake : https://explorer.solana.com/address/4EZRbSFYUQeuNCtY3Tv5tqprpTk9Ak7CZPzPsXKm1qLD?cluster=testnet
Stake2 : https://explorer.solana.com/address/967KrU4RrL2jrFtgyCKDBtyXrh3YC1SYh21PZvA6YJgE?cluster=testnet
When I check my vote account the rewards are there for the epoch
https://explorer.solana.com/address/7R5of8HZreWPjURAMupJuik7vx5SAGUghpwU648bWYnt?cluster=testnet
On the contrary, the stake account has not generated any rewards and they are in the Active (Delegated)
The vote account has a commission of 100%, so all of the rewards go to the vote account, with nothing going to the stakers. If you lower the commission, then your stake accounts will start to receiver rewards.

How to know Validator earning solana (Testnet)

Setup the Testnet Validator funded with some SOL in Testnet (Not real )
Here is the link for the Explorer
https://explorer.solana.com/address/GfudXfSxpvSBvkyNG7K1CdFhntZw3ASvBeCiTSRV5nzr?cluster=testnet
Stake Account Identity :EjGaPZ59sycMm46VpbukVY9PnwSdPYCfeQnbRLaZaD7m
Vote Account Identoty: 7R5of8HZreWPjURAMupJuik7vx5SAGUghpwU648bWYnt
Validator Identity:GfudXfSxpvSBvkyNG7K1CdFhntZw3ASvBeCiTSRV5nzr
The blocks are getting produced well in the Testnet Enviroment for the validator identity GfudXfSxpvSBvkyNG7K1CdFhntZw3ASvBeCiTSRV5nzr,
How to know the Validator earning where to check it ?
The validator's earnings are stored in the validator's vote account, so check on the SOL balance in 7R5of8HZreWPjURAMupJuik7vx5SAGUghpwU648bWYnt. The voting commissions are paid out every epoch, so you'll have to wait until the next epoch to see rewards in the vote account and stake account.

NEAR Locking Funds into smart contract

i'm quite struggling understanding how we can deposit and withdraw funds from smart contract on NEAR blockchain.
I'm currently using near-sdk-as with AssemblyScript. According to documentation I do have the
ContractPromiseBatch.create(recipient).transfert(amount)
But how can we lock funds into the smart contract and withdraw it from allowed accounts ?
When you call your method with --amount <some amount here> you have deposited these amounts to your contract balance. For example:
near call $CONTRACT add '{"url":"http://EXAPMLE.com", "title":"hello world"}' --accountId $AUTHOR --amount 3 //this is 3 NEARS you deposit to contract balance
When you want to send an amount from your contract balance to another person's balance you can use the contractPromiseBatch API as follows:
const toAnotherPerson = ContractPromiseBatch.create("anotherPerson.testnet");
toAnotherPerson.transfer(<some amount here>);

Transaction declined in magento 1.9 when testing with DPS PxPay2.0

I am getting transaction declined errors (The transaction was Declined (BH)) when using a test with DPS Payment Express account (PxPay 2.0) for processing credit cards on a website.I am using test credit card no 4111111111111111, expiry date is any future date ,any name for card holder name and 3 digit csv numer.
I am getting following error(response)
Response:DECLINED
Response Code:BH
Currency:USD
Amount: 2016.92
Card:411111........11
Card Holder:MANISH KUMAR
Card Type:Visa
Date:20141007
Time:060747
Transaction Type:Purchase
Help Text:The transaction was Declined (BH)
Can any one please help me....
It is solved by change the currency to NZD.
For others that are using PXPOST "The transaction was Declined (BH)" means that the port is not configured for the Currency you are trying to charge in.
In our case we already had a multi-currency merchant account with our bank but we had to call Payment Express and ask them to enable the new currency we were sending.

How to verify web text while excluding random vars with ruby/watir

I have this text and need to verify the bolded words only in each line:
Insured Direct Bill / 16.67%: $xxx.xx down, includes the Policy Fee and Financial Responsibility Fee, and 5 installments of $xxx.xx (does not include $x.xx installment fee)
Insured Direct Bill / 25%: $xxx.xx down, includes the Policy Fee and Financial Responsibility Fee, and 5 installments of $xxx.xx (does not include $x.xx installment fee)
Electronic Funds Transfer: $xxx.xx down, includes the Policy Fee and Financial Responsibility Fee, and 5 installments of $xxx.xx (does not include $x.xx installment fee)
I'm assuming I'll need to use:
foo = REGEX
#browser.text.include?(foo)
I'm stuck at how to get it to see everything other than the currency amounts. [^$\d+.\d+] excludes all the currency but includs the 5 and 16.67
Thanks
regex = /Insured Direct Bill \/ 25%: \$(\d+\.\d+) down, includes the Policy Fee and Financial Responsibility Fee, and 5 installments of \$(\d+\.\d+) \(does not include \$(\d+\.\d+) installment fee\)/
#browser.text.match(regex)
There are some regex lessons in Marick's book Everyday Scripting with Ruby. I recommend them to strengthen your capability if you need to use regex from time to time.

Resources