web3_storage 0.0.1 copy "web3_storage: ^0.0.1" to clipboard
web3_storage: ^0.0.1 copied to clipboard

Port of web3.storage SDK in Dart

example/lib/example.dart

import 'dart:convert';
import 'dart:io';
import 'dart:typed_data';

import 'package:web3_storage/web3_storage.dart';

void main() async {
  // You can grab an API Token here: https://web3.storage/tokens/
  final String apiToken = '<web3.storage_api_token>';

  final web3Storage = withApiToken(apiToken);

  // Create file reference model of what will be uploaded to Web3.storage
  final file = RawFile(
    name: 'hello',
    extension: 'txt',
    data: Uint8List.fromList(
      utf8.encode('Hello world'),
    ),
  );

  // Upload it
  final result = await web3Storage.upload(file: file);

  // Tadaaaaam! It should print your Web3 file IPFS CID
  print(result);

  exit(0);
}
4
likes
130
points
53
downloads

Publisher

unverified uploader

Weekly Downloads

Port of web3.storage SDK in Dart

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

dartz, http, networking

More

Packages that depend on web3_storage