File delete

You can only delete files that belong to you.

The reference code is as follows:

package main

import (
	"context"
	"fmt"

	cess "github.com/CESSProject/cess-go-sdk"
)

// Substrate well-known mnemonic:
//
//	https://github.com/substrate-developer-hub/substrate-developer-hub.github.io/issues/613
var MY_MNEMONIC = "bottom drive obey lake curtain smoke basket hold race lonely fit walk"

var RPC_ADDRS = []string{
	"wss://testnet-rpc0.cess.cloud/ws/",
	"wss://testnet-rpc1.cess.cloud/ws/",
	"wss://testnet-rpc2.cess.cloud/ws/",
}

// fid to be deleted
var fid_delete = "c9f43f8d1e5501599e91dbd59420d44a33982d74fab250838f1a3f5a59a33ae6"

func main() {
	sdk, err := cess.New(
		context.Background(),
		cess.ConnectRpcAddrs(RPC_ADDRS),
		cess.Mnemonic(MY_MNEMONIC),
	)
	if err != nil {
		panic(err)
	}

	// delete file
	fmt.Println(sdk.DeleteFile(sdk.GetSignatureAccPulickey(), []string{fid_delete}))
}

Last updated