➖TUTORIALS
IN FEW EASY STEPS YOU WILL BE ABLE TO DEPLOY VERY POWERFUL BOT
Last updated
IN FEW EASY STEPS YOU WILL BE ABLE TO DEPLOY VERY POWERFUL BOT
Last updated
Getting started
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
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.
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
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
npm install
.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 {
}
npm run build
Installation should be ready now, proceed to next step.
Running Bot
From my experience i recommend you run screen Session for your Bots instance.
screen -S yourbotsname
Now you can finally Start a bot, here are few run modes possible:
npm run start
npm run start:dev
npm run start:prod
npm run start:prod-with-watchdog
ctrl a + d
screen -r yourbotsname
Stats Commands
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:
/owned <wallet>
/userstats <wallet>
/volume <time frame>
/graph
/traders <time frame>
/transaction <tx>
/index <block> <tx>
/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
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.
/createpoll <description> <duration> <role> <emojis> <link> <minimumvotes>
/pollresults <poll id>
/closepoll <poll id>
/deletepoll <poll id>
/listpolls
/bindweb3
/bindtwitter
/bounded
To learn more about DAO Module and how it works go to GOVERNANCE
CLI Commands
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.
npm run cli -- --action=tweet --contract=your-contract-here --block=block-number --tx=transaction-hash
npm run cli -- --action=index --contract=your-contract-here --block=block-number --tx=transaction-hash