Ankr: Create a Truffle Project with Ankr and Filebase
Learn how to create a Truffle Project with Ankr and Filebase.
Last updated
Learn how to create a Truffle Project with Ankr and Filebase.
Last updated
Ankr is an API and blockchain node utility that can be used to create API projects and deploy your own blockchain nodes.
The Ankr API can be used in a variety of different applications, making it useful for project development and application creation. Ankr offers a selection of public API endpoints, so there is no need for an account to get started. To create custom, private apps, check out their guide on creating your own Ethereum API endpoint here.
In this guide, we’ll use Truffle, Ganache, and Ankr to create an example app located on a local development environment using the Ropsten blockchain network with files backed up to an IPFS bucket on Filebase.
This guide was written and tested using Ubuntu 20.04. Commands and workflow may vary depending on your operating system.
To do this, navigate to console.filebase.com. If you don’t have an account already, sign up, then log in.
Select ‘Create Bucket’ in the top right corner to create a new bucket.
Bucket names must be unique across all Filebase users, be between 3 and 63 characters long, and can contain only lowercase characters, numbers, and dashes.
Set up a credentials file for S3FS at ${HOME}/.passwd-s3fs.
You will need to save your Filebase Access and Secret keys to this file and give it owner permissions. You can do so with the following commands:
echo ACCESS_KEY_ID:SECRET_ACCESS_KEY > ${HOME}/.passwd-s3fs
chmod 600 ${HOME}/.passwd-s3fs
ACCESS_KEY_ID is your Filebase Access key, and SECRET_ACCESS_KEY is your Filebase Secret key. For more information on Filebase access keys, see here.
You can mount a Filebase IPFS bucket with the command:
s3fs mybucket /path/to/mountpoint -o passwd_file=${HOME}/.passwd-s3fs -o url=https://s3.filebase.com
mybucket: name of your Filebase bucket
/path/to/mountpoint
cd /path/to/mounted/bucket
mkdir truffle-project
cd truffle-project
npm init
Provide any necessary configuration options for your workspace, or accept the default configuration settings for your npm workspace.
npm install -g truffle
npm install ganache --global
npm install -g webpack
truffle unbox webpack
Your project will have the following files and directories:
app/
contracts/
migrations/
test/
truffle-config.js
example.sol
with the following content:This is a very basic contract that does a multiplication problem. There are a variety of different types of contracts, the most common being contracts for minting NFTs. You can find a variety of guides that go in depth in the creation of NFT contracts [here].
2_deploy_contracts.js
with the following content:truffle-hdwallet-provider
and the babel-register
packages with the following commands:npm init
npm install babel-register truffle-hdwallet-provider --save
This contract uses the Ankr public Ethereum endpoint. Learn more about Ankr by checking out their website here.
truffle compile
truffle migrate --network networkName
From here, you can create new contracts and deploy them in the same way you deployed this example contract. You can create contracts for almost anything, including minting NFTs or transferring tokens.