To deploy and set authority, have a default keypair associated with your solana config
Mock bidder and lister keypairs are already present, but you need to
- Fund them
- Create a token
- Create token accounts for both users and send tokens accordingly
This can be done as follows
git clone git@github.com:Coinmeca/nft-trading-platform.git
cd nft-trading-platform.git
REPO_PATH=.
solana config set -u devnet -k ~/.config/solana/id.json
solana airdrop 1
solana airdrop 10 $REPO_PATH/dist/bidder/bidder-keypair.json
solana airdrop 10 $REPO_PATH/dist/lister/lister-keypair.json
export TOKEN_MINT=$(spl-token create-token --decimals 0 | grep "Creating token" | cut -d" " -f3)
export BIDDER_TOKEN_ADDRESS=$(spl-token create-account $TOKEN_MINT --owner $REPO_PATH/dist/bidder/bidder-keypair.json | grep "Creating account" | cut -d" " -f3)
export LISTER_TOKEN_ADDRESS=$(spl-token create-account $TOKEN_MINT --owner $REPO_PATH/dist/lister/lister-keypair.json | grep "Creating account" | cut -d" " -f3)
spl-token mint $TOKEN_MINT 1 $LISTER_TOKEN_ADDRESS
spl-token authorize $TOKEN_MINT mint --disable
npm run build:program-rust
solana program deploy $REPO_PATH/dist/program/test.so
npm run init
Go to $REPO_PATH/src/client/test.ts
and replace the top level tokenMintPubKey
with your new token $TOKEN_MINT
You can list the token created above by running `npm run list`
You can delist the token created above by running `npm run delist`
You can bid for the token created above by running `npm run bid`
You can withdraw bid for the token created above by running `npm run withdraw-bid`
A trade can happen two ways (a lister accepts a bid, or a bidder accepts a listing)
* Lister can accept a bid using `npm run accept-bid`
--Note: Both a listing and a bid should be present in order to call `AcceptBid`. `AcceptBid` is a non-inavsive instruction, that is, it doesn't assume that the bidder has a token account yet. After a successful trade, the bidder can create a token account and call the `WithdrawOnSuccess` instruction. We have already set up the bidder account, so you can simply call call `npm run withdraw-on-success`
* Bidder can accept lisitng using `npm run accept-listing`
A bid doesn't need to be placed to accept a listing as is. That is, a listing can be accepted at the designated listing price without setting up a bidding escrow
The program authority can close escrows and refund bidders at will by calling the RefundUser
instruction. Run npm run refund
to refund the test bidder
The admin can set a new authority or change platform fees using the ChangeAuthority
and ChangeFee
instructions