-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
integrate irys as an asset uploader service
- Loading branch information
Showing
11 changed files
with
3,355 additions
and
1,763 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Account, AptosConfig, Network, Aptos, AssetUploader } from "@aptos-labs/ts-sdk"; | ||
|
||
const example = async () => { | ||
const account = Account.generate(); | ||
const aptosConfig = new AptosConfig({ | ||
network: Network.TESTNET, | ||
}); | ||
const aptos = new Aptos(aptosConfig); | ||
|
||
const assetUploader = await AssetUploader.init(aptosConfig); | ||
|
||
await aptos.fundAccount({ accountAddress: account.accountAddress, amount: 1_000_000 }); | ||
|
||
// Fund a node | ||
const fundResponse = await assetUploader.fundNode({ account, amount: 1000 }); | ||
console.log("fund response", fundResponse); | ||
|
||
// Upload data | ||
const uploadDataResponse = await assetUploader.uploadData({ account, data: "Hello Aptos" }); | ||
console.log("upload response", uploadDataResponse); | ||
|
||
// Upload file | ||
const uploadFileResponse = await assetUploader.uploadFile({ | ||
account, | ||
filePathToUpload: "<path-to-file>", | ||
}); | ||
console.log("uploadFileResponse", uploadFileResponse); | ||
|
||
// Upload folder | ||
const uploadFolderResponse = await assetUploader.uploadFolder({ | ||
account, | ||
folderToUpload: "<path-to-folder>", | ||
}); | ||
console.log("uploadFolderResponse", uploadFolderResponse); | ||
process.exit(0); | ||
}; | ||
|
||
example(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.