Filecoin Master Class // Intro to Buckets
Filecoin Master Class // Intro to Buckets
Into the Powergate - Andrew Hill & Aaron Sutula
Into the Powergate - Andrew Hill & Aaron Sutula
// ETH/Polygon
import "@openzeppelin/.../Initializable.sol";
import "@openzeppelin/.../OwnableUpgradeable.sol";
import "@openzeppelin/.../EnumerableSetUpgradeable.sol";
contract BridgeRegistry is Initializable, OwnableUpgradeable {
// Events
event AddProvider(address indexed provider);
event RemoveProvider(address indexed provider);
// API
function addProvider(address provider) public onlyOwner;
function listProviders() public view returns (address[] memory);
function removeProvider(address provider) public onlyOwner;
}
// NEAR
import "@textile/ownable/assembly";
// Logging
function ProviderAdded(provider: string): void;
function ProviderRemoved(provider: string): void;
// API
export function addProvider(provider: string): void;
export function removeProvider(provider: string): void;
export function listProviders(): string[];
// ETH/Polygon
contract BridgeProvider is Initializable, OwnableUpgradeable {
// Parameter
string public apiEndpoint;
// Events
event AddDeposit(
address indexed depositee,
address indexed depositor,
uint256 amount
);
event ReleaseDeposit(
address indexed depositee,
address indexed depositor,
uint256 amount
);
// API
function addDeposit(address depositee) public payable;
function hasDeposit(address depositee) public view returns (bool);
function releaseDeposit(address depositee) public;
function releaseDeposits() public;
}
// NEAR
import "@textile/ownable/assembly";
// Parameter
export function apiEndpoint(): string;
// Logging
function DepositAdded(depositee: string, depositor: string, amount: u128): void;
function DepositReleased(
depositee: string,
depositor: string,
amount: u128
): void;
// API
export function addDeposit(depositee: string): void;
export function hasDeposit(depositee: string): bool;
export function releaseDeposits(
start: u32 = 0,
end: u32 = deposits.length
): void;
Textile | Introduction to the Filecoin Bridge
Textile | Introduction to the Filecoin Bridge
import { providers } from "ethers";
import { init, requestSignIn } from "@textile/eth-storage";
await requestSignIn();
const provider = new providers.Web3Provider(window.ethereum);
const wallet = provider.getSigner();
const storage = await init(wallet);
const blob = new Blob(["Hello, world!"], { type: "text/plain" });
const file = new File([blob], "welcome.txt", {
type: "text/plain",
lastModified: new Date().getTime()
});
await storage.addDeposit();
const { id, cid } = await storage.store(file);
const { request, deals } = await storage.status(id);
console.log(request.status_code);
console.log([...deals]);
import { connect, WalletConnection } from "near-api-js";
import { init, requestSignIn } from "@textile/near-storage";
const near = await connect({ ... });
const wallet = new WalletConnection(near, null);
await requestSignIn(wallet);
const storage = init(wallet.account());
const blob = new Blob(["Hello, world!"], { type: "text/plain" });
const file = new File([blob], "welcome.txt", {
type: "text/plain",
lastModified: new Date().getTime(),
});
await storage.addDeposit();
const { id, cid } = await storage.store(file);
const { request, deals } = await storage.status(id)
console.log(request.status_code)
console.log([...deals])
await wallet.signOut();
Textile

Textile

  • 12.
    Filecoin Master Class// Intro to Buckets Filecoin Master Class // Intro to Buckets
  • 15.
    Into the Powergate- Andrew Hill & Aaron Sutula Into the Powergate - Andrew Hill & Aaron Sutula
  • 22.
    // ETH/Polygon import "@openzeppelin/.../Initializable.sol"; import"@openzeppelin/.../OwnableUpgradeable.sol"; import "@openzeppelin/.../EnumerableSetUpgradeable.sol"; contract BridgeRegistry is Initializable, OwnableUpgradeable { // Events event AddProvider(address indexed provider); event RemoveProvider(address indexed provider); // API function addProvider(address provider) public onlyOwner; function listProviders() public view returns (address[] memory); function removeProvider(address provider) public onlyOwner; } // NEAR import "@textile/ownable/assembly"; // Logging function ProviderAdded(provider: string): void; function ProviderRemoved(provider: string): void; // API export function addProvider(provider: string): void; export function removeProvider(provider: string): void; export function listProviders(): string[];
  • 23.
    // ETH/Polygon contract BridgeProvideris Initializable, OwnableUpgradeable { // Parameter string public apiEndpoint; // Events event AddDeposit( address indexed depositee, address indexed depositor, uint256 amount ); event ReleaseDeposit( address indexed depositee, address indexed depositor, uint256 amount ); // API function addDeposit(address depositee) public payable; function hasDeposit(address depositee) public view returns (bool); function releaseDeposit(address depositee) public; function releaseDeposits() public; }
  • 24.
    // NEAR import "@textile/ownable/assembly"; //Parameter export function apiEndpoint(): string; // Logging function DepositAdded(depositee: string, depositor: string, amount: u128): void; function DepositReleased( depositee: string, depositor: string, amount: u128 ): void; // API export function addDeposit(depositee: string): void; export function hasDeposit(depositee: string): bool; export function releaseDeposits( start: u32 = 0, end: u32 = deposits.length ): void;
  • 26.
    Textile | Introductionto the Filecoin Bridge Textile | Introduction to the Filecoin Bridge
  • 29.
    import { providers} from "ethers"; import { init, requestSignIn } from "@textile/eth-storage"; await requestSignIn(); const provider = new providers.Web3Provider(window.ethereum); const wallet = provider.getSigner(); const storage = await init(wallet); const blob = new Blob(["Hello, world!"], { type: "text/plain" }); const file = new File([blob], "welcome.txt", { type: "text/plain", lastModified: new Date().getTime() }); await storage.addDeposit(); const { id, cid } = await storage.store(file); const { request, deals } = await storage.status(id); console.log(request.status_code); console.log([...deals]);
  • 30.
    import { connect,WalletConnection } from "near-api-js"; import { init, requestSignIn } from "@textile/near-storage"; const near = await connect({ ... }); const wallet = new WalletConnection(near, null); await requestSignIn(wallet); const storage = init(wallet.account()); const blob = new Blob(["Hello, world!"], { type: "text/plain" }); const file = new File([blob], "welcome.txt", { type: "text/plain", lastModified: new Date().getTime(), }); await storage.addDeposit(); const { id, cid } = await storage.store(file); const { request, deals } = await storage.status(id) console.log(request.status_code) console.log([...deals]) await wallet.signOut();