This is the monorepo for the truffle preserve framework which includes:
- @truffle/preserve which is the preserve framework
- @truffle/preserve-fs, which represents the thing you want to preserve, files
- @truffle/preserve-to-buckets, needed to preserve your thing to textile buckets
- @truffle/preserve-to-filecoin, needed to preserve your thing to filecoin
- @truffle/preserve-to-ipfs, needed to preserve your thing to IPFS
The truffle preserve
command comes preconfigured with the ability to preserve files to IPFS, Filecoin or Textile Buckets.
To preserve your files to IPFS use the --ipfs
flag.
$ truffle preserve ./path --ipfs [--environment <name>]
By default, the connection to IPFS is done with a local node presumed to be running at http://localhost:5001
. This is the default for an ipfs
daemon and also for ganache filecoin
. It is possible to point to a different IPFS node by configuing a different URL in a truffle-config.js
environment.
module.exports = {
/* ... rest of truffle-config */
environments: {
/* ... other environments */
production: {
ipfs: {
address: "https://ipfs.infura.io:5001",
},
},
},
};
To preserve your files to Filecoin use the --filecoin
flag.
$ truffle preserve ./path --filecoin [--environment <name>]
By default, the connection to Filecoin is done with a local node presumed to be running at http://localhost:7777/rpc/v0
. This is the default for a mainnet or localnet Lotus or Powergate node and also for ganache filecoin
. It is possible to point to a different Filecoin node by configuing a different URL in a truffle-config.js
environment. Besides the connection URL, you can also configure Filecoin storage deal options such as the duration or price.
module.exports = {
/* ... rest of truffle-config */
environments: {
/* ... other environments */
development: {
filecoin: {
address: "http://localhost:1234/rpc/v0",
token: "AUTH_TOKEN",
storageDealOptions: {
epochPrice: "2500",
duration: 518400, // 180 days
},
},
},
},
};
To preserve your files to Textile Buckets use the --buckets
flag.
$ truffle preserve ./path --buckets [--environment <name>]
Textile Buckets requires some configuration in order to work with truffle preserve
. To get started, you need to install Textile's hub
tool, register and create authentication keys.
hub init
hub keys create
- account
- Require Signature Authentication (recommended): N
After generating these keys, they need to be added to an environment in your truffle-config.js
file as well as the name of the bucket that you want to preserve your files to - it's possible to use an existing bucket for this, or if it doesn't exist yet it will be created in the process.
module.exports = {
/* ... rest of truffle-config */
environments: {
/* ... other environments */
development: {
buckets: {
key: "MY_BUCKETS_KEY",
secret: "MY_BUCKETS_SECRET",
bucketName: "truffle-preserve-bucket",
},
},
},
};
While Truffle comes bundled with support for IPFS, Filecoin and Textile Buckets, additional workflows (or recipes) can be defined and used.
- Install the plugin from NPM.
npm install --save-dev truffle-preserve-to-my-server
- Add a
plugins
section to your Truffle config.
module.exports = {
/* ... rest of truffle-config */
plugins: ["truffle-preserve-to-my-server"],
};
- Add any required configuration options to your Truffle config if it's required by the plugin. Refer to the plugin's documentation for this.
After installation and configuration, the plugin's tag (e.g. --my-server
) will show up in truffle help preserve
and can be used with truffle preserve
.
truffle preserve ./path --my-server
Refer to the following resources to get started creating your own custom recipes: