➖TUTORIALS
IN FEW EASY STEPS YOU WILL BE ABLE TO DEPLOY VERY POWERFUL BOT
Getting started
Getting started
THINGS YOU WILL NEED
Linux Server (ubuntu 20.04).
Twitter v2 API access.
Alchemy API Key.
Node.js v18.x
Discord APP token.
Discord Server Admin access.
Some Basic coding/editing knowledge.
Prerequisite
Prerequisite
ACCOUNTS AND ACCESS TOKENS
TWITTER
To get your twitter API keys, follow this tutorial.
Now you need Access keys with read and write permission, follow this tutorial.
Save both, your API and Access keys for deployment.
(optional) to obtain Access keys of another User, follow this tutorial.
DISCORD
To get Discord bot token, follow this tutorial.
Save your Discord token for deployment.
Now you will need to generate link with proper permissions to invite your Discord bot to your Server. In your developer portal under
0Auth2/URL Generator
check this boxes:
This will generate URL that you can use to invite Bot to your Discord server with proper permissions for it to post sales and other Application Commands.
Discord bot should now be ready to post sales, if you get stuck dm me on twitter @iape_
Deployment
Deployment
INSTALLATION
On your ubuntu server first clone PhunkBot repository
git clone https://github.com/Crypto-Phunks/nft-sales-twitter-bot.git
Go to Bots directory
cd nft-sales-twitter-bot
Run installation
npm install
Create .env
file
.env
filenano .env
Add content from example.env
and enter your API credentials
TWITTER_ACCESS_TOKEN_KEY=""
TWITTER_ACCESS_TOKEN_SECRET=""
TWITTER_API_KEY=""
TWITTER_API_KEY_SECRET=""
ALCHEMY_API_KEY=""
DISCORD_TOKEN=""
GETH_NODE_ENDPOINT=""
GETH_NODE_ENDPOINT_HTTP=""
Edit the src/config.ts
file
nano src/config.ts
Add your Smart Contract and Discord IDs
// Contract Address ======================================== //
contract_address: 'your-NFT-smart-contract',
nftx_vault_contract_address: '',
// Enter the block where your contract has been created
statistic_initial_block: 13035326,
//
discord_channels: 'your-discord-channel-ID-where-bot-posts-sales',
discord_client_id: 'your-discord-APP-ID',
discord_guild_ids: 'your-discord-Server-ID',
Customise the Tweet and Discord Stats parameters
ownedTokensMessageDiscord: '<wallet> owns <count> Phunks!\n———\n',
graphStatisticsMessageDiscord: 'Here is the graph you requested for [<wallet>]!\n———\n',
userStatisticsMessageDiscord: 'Stats for <wallet>!\n———\n\n⏳ Flipped to Phunk for the first time [<holder_since>] days ago.\n💰 Flipped Phunks [<tx_count>] times with a total volume of [Ξ<volume>]\n💎 Is currently holding [<owned_tokens>] Phunks.',
globalStatisticsMessageDiscord: 'Here are volume stats for [<window>]! 💰\n\n<per_platform_stats>\n\nlast tx fetched [<last_event>]',
saleMessageDiscord: '[Phunk #<tokenId>](<tweetLink>) was flipped for [<ethPrice> (<fiatPrice>)](<https://etherscan.io/tx/<txHash>>)\nfrom: [<from>](<https://notlarvalabs.com/cryptophunks/phunkbox?address=<initialFrom>>)\nto: [<to>](<https://notlarvalabs.com/cryptophunks/phunkbox?address=<initialTo>>)',
saleMessage: 'Phunk #<tokenId> was flipped for <ethPrice> (<fiatPrice>) by <to>\n| https://notlarvalabs.com/cryptophunks/details/<tokenId>\n',
bidMessageDiscord: '[Phunk #<tokenId>](<tweetLink>) has a bid for [<ethPrice> (<fiatPrice>)](https://notlarvalabs.com/cryptophunks/details/<tokenId>)\nfrom: [<from>](<https://notlarvalabs.com/cryptophunks/phunkbox?address=<initialFrom>>)',
bidMessage: 'Phunk #<tokenId> has a bid for <ethPrice> (<fiatPrice>) from <from>\n| https://notlarvalabs.com/cryptophunks/details/<tokenId>\n',
flywheelMessageDiscord: '[Phunk #<tokenId>](<tweetLink>) was flipped to FlyWheel for [<ethPrice> (<fiatPrice>)](<https://etherscan.io/tx/<txHash>>)\nby: [<to>](<https://notlarvalabs.com/cryptophunks/phunkbox?address=<initialTo>>)',
flywheelMessage: 'Phunk #<tokenId> was flipped to FlyWheel for <ethPrice> (<fiatPrice>) by <to>\n| https://notlarvalabs.com/cryptophunks/details/<tokenId>\n| https://phunks.pro',
auctionMessageDiscord: '[Phunk #<tokenId>](<tweetLink>) was Auctioned for [<ethPrice> (<fiatPrice>)](<additionalText>)\nto: [<to>](<https://notlarvalabs.com/cryptophunks/phunkbox?address=<initialTo>>)',
auctionMessage: 'Phunk #<tokenId> was Auctioned for <ethPrice> (<fiatPrice>) to <to>\n| https://notlarvalabs.com/cryptophunks/details/<tokenId>\n| <additionalText>',
loanMessage: 'Phunk #<tokenId> was flipped for <ethPrice> (<fiatPrice>) by <to>\n| https://notlarvalabs.com/cryptophunks/details/<tokenId>\n',
(Optional) Use Local images and Local metadata
use_local_images: true,
local_image_path: './token_images/phunk',
use_forced_remote_image_path: false,
forced_remote_image_path: '',
enable_flashbot_detection: false,
//
// this is a configuration for the phunk bid demo extension
local_bids_image_path: './bids_images/Phunk_',
discord_owned_tokens_image_path: '',
discord_footer_text: 'FLIP!',
// this is a configuration for the phunk auction house demo extension
local_auction_image_path: './token_images/phunk',
token_metadata_cache_path: './token_metadatas_cache',
The local_image_path
will be suffixed with the token number, ie, here, it will seek for an image named ./token_images/tokens0034.png
if the token #34 is sold.
(Optional) Edit src/app.module.ts
file and activate/deactivate services (providers) //
@Module({
imports: [
HttpModule,
ServeStaticModule.forRoot({
rootPath: join(__dirname, '..', 'client'),
})],
providers: [
Erc721SalesService,
////
// Below is a simple example of how to create and plug a custom
// extension to the bot
////
//
PhunksBidService,
PhunksAuctionHouseService,
PhunksAuctionFlywheelService,
StatisticsService
],
controllers: [
DAOController
],
})
export class AppModule {
}
Build and Deploy
npm run build
Installation should be ready now, proceed to next step.
Running Bot
Running Bot
START
From my experience i recommend you run screen Session for your Bots instance.
within installation directory start a new screen Session
screen -S yourbotsname
Now you can finally Start a bot, here are few run modes possible:
development
npm run start
watch mode
npm run start:dev
production mode
npm run start:prod
with watchdog (recommended)
npm run start:prod-with-watchdog
detach from screen Session
ctrl a + d
enter the screen Session back
screen -r yourbotsname
Stats Commands
Stats Commands
ON DISCORD
If you have Statistics module in src/app.module.ts
enabled, your Discord bot will gain some super powers.
Note: indexing (sync) can take up to 24h, depending on volume and age of your project.
Here is the list of available commands:
Display a list of the owned tokens by a wallet
/owned <wallet>
Display some interesting stats by wallet
/userstats <wallet>
Display collection volume across all markets for given time frame
/volume <time frame>
Display a graph showing the average price and the volume of Collection over time
/graph
Display the top 20 traders of your Collection for given time frame
/traders <time frame>
Displays indexed info about a given transaction, useful for debugging purposes
/transaction <tx>
Force index of the given transaction within the given block
/index <block> <tx>
Check your Bots current index block number (heartbeat)
/status
You will need to set starting block of your collection under /src/config.ts.
// Enter the block where your contract has been created
statistic_initial_block: 18035326,
//
DAO Commands
DAO Commands
ON DISCORD
If you have DAO Module in src/app.module.ts
enabled, your Discord bot will gain some amazing super powers. Since we are dealing with community Governance here, commands are split into two categories: Admin and User commands.
Admin Commands
Create Poll for users with allowed role (optional) to vote
/createpoll <description> <duration> <role> <emojis> <link> <minimumvotes>
Get detailed Poll results, only visible to Admins
/pollresults <poll id>
Close Poll, forced command
/closepoll <poll id>
Delete Poll, forced command
/deletepoll <poll id>
User Commands
List all active Polls
/listpolls
Bind web3 wallet to your Discord account
/bindweb3
Bind twitter account to your Discord account
/bindtwitter
List bounded web3 wallet(s) and twitter account to your Discord account
/bounded
To learn more about DAO Module and how it works go to GOVERNANCE
CLI Commands
CLI Commands
REPLAY TRANSACTION
You might occur situation where you want to repost missed sale or replay specific transaction to monitor bots behaviour and debug. This is where CLI extension comes in very handy.
To replay transaction with tweeting, run within installation directory
npm run cli -- --action=tweet --contract=your-contract-here --block=block-number --tx=transaction-hash
To replay transaction for indexing and debugging, run within installation directory
npm run cli -- --action=index --contract=your-contract-here --block=block-number --tx=transaction-hash
Last updated