Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Command = &cobra.Command{ Use: "token", Short: "T0ken utilities", } DeployCommand = &cobra.Command{ Use: "deploy <name> <symbol> <decimals>", Short: "Deploys a new t0ken contract", Example: "t0ken token deploy --keystoreAddress owner", Args: cli.ChainArgs(cobra.ExactArgs(3), cli.UintArgFunc("decimals", 2, 8)), PreRun: commands.ConnectWithKeyStore, Run: func(cmd *cobra.Command, args []string) { name := args[0] symbol := args[1] decimals, err := strconv.ParseInt(args[2], 10, 8) addr, tx, _, err := t.DeployT0ken(cli.Conn.Opts, cli.Conn.Client, name, symbol, uint8(decimals)) cli.CheckErr(cmd, err) cmd.Println(" Contract:", addr.String()) cli.PrintTransactionFn(cmd)(tx, nil) }, } AuditCommand = &cobra.Command{ Use: "audit", Short: "Audit the holders of the t0ken, outputting CSV to <stdout>", Example: `t0ken token audit t0ken token audit --block 8658083`, PreRun: connectCaller, Run: func(cmd *cobra.Command, arts []string) { if callSession.CallOpts.BlockNumber == nil { header, err := cli.Conn.HeaderByNumber(context.Background(), nil) cli.CheckErr(cmd, err) callSession.CallOpts.BlockNumber = header.Number } n, err := callSession.Holders() cli.CheckErr(cmd, err) one := big.NewInt(1) index := big.NewInt(0) cmd.Printf("Block: %s\n", callSession.CallOpts.BlockNumber.String()) fmt.Println("address,tokens") for i := int64(0); i < n.Int64(); i++ { holder, err := callSession.HolderAt(index) cli.CheckErr(cmd, err) balance, err := callSession.BalanceOf(holder) cli.CheckErr(cmd, err) fmt.Printf("%s,%s\n", holder.String(), balance.String()) index.Add(index, one) } }, } )
View Source
var FilterCommands = []*cobra.Command{ &cobra.Command{ Use: "filterTransfer", Short: "Filters transfer events within the given block range", Example: `t0ken token filterTransfer --start 8658083 t0ken token filterTransfer --start 8658083 --end 8700000 t0ken token filterTransfer --from 0xf01fF29DCbEE147e9cA151a281bFdf136f66A45b t0ken token filterTransfer --to 0xf01fF29DCbEE147e9cA151a281bFdf136f66A45b,0xf02f537578d03f6AeCE28F249eaC19542D848F20`, PreRun: connectFilterer, Run: func(cmd *cobra.Command, args []string) { from, err := cli.AddressesFlag(cmd, "from", false) cli.CheckErr(cmd, err) to, err := cli.AddressesFlag(cmd, "to", false) cli.CheckErr(cmd, err) opts := cli.FilterOpts(cmd) i, err := filterer.FilterTransfer(&opts, from, to) cli.CheckErr(cmd, err) defer i.Close() fmt.Println("block,from,to,value") for i.Next() { cli.CheckErr(cmd, i.Error()) fmt.Printf("%d,%s,%s,%s\n", i.Event.Raw.BlockNumber, i.Event.From.String(), i.Event.To.String(), i.Event.Value) } }, }, }
View Source
var GetterCommands = []*cobra.Command{ &cobra.Command{ Use: "abi", Short: "Outputs the T0ken ABI", Example: "t0ken investor abi", Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { cmd.Println(t.T0kenABI) }, }, &cobra.Command{ Use: "bin", Short: "Outputs the T0ken Binary", Example: "t0ken investor bin", Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { cmd.Println(t.T0kenBin) }, }, &cobra.Command{ Use: "allowance <owner> <spender>", Short: "Gets the amount of tokens the <owner> has approved the <spender> to transfer", Example: "t0ken token allowance 0xf01ff29dcbee147e9ca151a281bfdf136f66a45b 0xa01a0a93716633058d69a28fbd472fd40e7c6b79", Args: cli.ChainArgs(cobra.ExactArgs(2), cli.AddressArgFunc("owner", 0), cli.AddressArgFunc("spender", 1)), PreRun: connectCaller, Run: func(cmd *cobra.Command, args []string) { owner := common.HexToAddress(args[0]) spender := common.HexToAddress(args[1]) cli.CheckGetter(cmd)(callSession.Allowance(owner, spender)) }, }, &cobra.Command{ Use: "balanceOf <address>", Short: "Gets the balance of the given <address>", Example: "t0ken token balanceOf 0xf01ff29dcbee147e9ca151a281bfdf136f66a45b", Args: cli.ChainArgs(cobra.MaximumNArgs(1), cli.AddressArgFunc("address", 0)), PreRun: connectCaller, Run: func(cmd *cobra.Command, args []string) { addr := common.HexToAddress(args[0]) cli.CheckGetter(cmd)(callSession.BalanceOf(addr)) }, }, &cobra.Command{ Use: "compliance", Short: "Gets the compliance contract address for the t0ken", Example: "t0ken token compliance", Args: cobra.NoArgs, PreRun: connectCaller, Run: func(cmd *cobra.Command, args []string) { cli.CheckAddressGetter(cmd)(callSession.Compliance()) }, }, &cobra.Command{ Use: "decimals", Short: "Gets the number of decimals the t0ken is set to", Example: "t0ken token decimals", Args: cobra.NoArgs, PreRun: connectCaller, Run: func(cmd *cobra.Command, args []string) { cli.CheckGetter(cmd)(callSession.Decimals()) }, }, &cobra.Command{ Use: "holderAt <index>", Short: "Gets the holder address at the given <index>", Example: "t0ken token holderAt 5", Args: cli.ChainArgs(cobra.MaximumNArgs(1), cli.IntArgFunc("index", 0)), PreRun: connectCaller, Run: func(cmd *cobra.Command, args []string) { index, _ := new(big.Int).SetString(args[0], 10) cli.CheckAddressGetter(cmd)(callSession.HolderAt(index)) }, }, &cobra.Command{ Use: "isHolder <address>", Short: "Checks if the given <address> is a current holder", Example: "t0ken token isHolder 0xf01ff29dcbee147e9ca151a281bfdf136f66a45b", Args: cli.ChainArgs(cobra.MaximumNArgs(1), cli.AddressArgFunc("address", 0)), PreRun: connectCaller, Run: func(cmd *cobra.Command, args []string) { addr := common.HexToAddress(args[0]) cli.CheckGetter(cmd)(callSession.IsHolder(addr)) }, }, &cobra.Command{ Use: "issuer", Short: "Gets the issuer of the t0ken", Example: "t0ken token issuer", Args: cobra.NoArgs, PreRun: connectCaller, Run: func(cmd *cobra.Command, args []string) { cli.CheckAddressGetter(cmd)(callSession.Issuer()) }, }, &cobra.Command{ Use: "issuanceFinished", Short: "Returns if issuance has been finished", Example: "t0ken token issuanceFinished", Args: cobra.NoArgs, PreRun: connectCaller, Run: func(cmd *cobra.Command, args []string) { cli.CheckGetter(cmd)(callSession.IssuanceFinished()) }, }, &cobra.Command{ Use: "name", Short: "Gets the name of the t0ken", Example: "t0ken token name", Args: cobra.NoArgs, PreRun: connectCaller, Run: func(cmd *cobra.Command, args []string) { cli.CheckGetter(cmd)(callSession.Name()) }, }, &cobra.Command{ Use: "holders", Short: "Gets the total number of holders", Example: "t0ken token holders", Args: cobra.NoArgs, PreRun: connectCaller, Run: func(cmd *cobra.Command, args []string) { cli.CheckGetter(cmd)(callSession.Holders()) }, }, &cobra.Command{ Use: "symbol", Short: "Gets the symbol of the t0ken", Example: "t0ken token symbol", Args: cobra.NoArgs, PreRun: connectCaller, Run: func(cmd *cobra.Command, args []string) { cli.CheckGetter(cmd)(callSession.Symbol()) }, }, &cobra.Command{ Use: "totalSupply", Short: "Gets the total supply", Example: "t0ken token totalSupply", Args: cobra.NoArgs, PreRun: connectCaller, Run: func(cmd *cobra.Command, args []string) { cli.CheckGetter(cmd)(callSession.TotalSupply()) }, }, }
View Source
var SetterCommands = []*cobra.Command{ &cobra.Command{ Use: "approve <address> <tokens>", Short: "Approves <address> to transfer <tokens> on your behalf", Example: "t0ken token approve 0xf01ff29dcbee147e9ca151a281bfdf136f66a45b 0xa01a0a93716633058d69a28fbd472fd40e7c6b79 --keystoreAddress 0xf01ff29dcbee147e9ca151a281bfdf136f66a45b", Args: cli.ChainArgs(cobra.MaximumNArgs(2), cli.AddressArgFunc("address", 0), cli.BigIntArgFunc("tokens", 1)), PreRun: connectTransactor, Run: func(cmd *cobra.Command, args []string) { addr := common.HexToAddress(args[0]) quantity, _ := new(big.Int).SetString(args[1], 10) cli.PrintTransactionFn(cmd)(transSession.Approve(addr, quantity)) }, }, &cobra.Command{ Use: "finishIssuance", Short: "Finishes issuance for the token (can't be undone)", Example: "t0ken token finishIssuance --keystoreAddress issuer", Args: cobra.NoArgs, PreRun: connectTransactor, Run: func(cmd *cobra.Command, args []string) { cli.PrintTransactionFn(cmd)(transSession.FinishIssuance()) }, }, &cobra.Command{ Use: "issueTokens <quantity>", Short: "Issues <quantity> of tokens to the issuer", Example: "t0ken token issueTokens 5000 --keystoreAddress issuer", Args: cli.IntArgFunc("quantity", 0), PreRun: connectTransactor, Run: func(cmd *cobra.Command, args []string) { quantity, _ := new(big.Int).SetString(args[0], 10) cli.PrintTransactionFn(cmd)(transSession.IssueTokens(quantity)) }, }, &cobra.Command{ Use: "setCompliance <address>", Short: "Sets the compliance contract <address>", Example: "t0ken token setCompliance 0x397e7b9c15ff22ba67ec6e78f46f1e21540bcb36 --keystoreAddress owner", Args: cli.ChainArgs(cobra.ExactArgs(1), cli.AddressArgFunc("address", 0)), PreRun: connectTransactor, Run: func(cmd *cobra.Command, args []string) { addr := common.HexToAddress(args[0]) cli.PrintTransactionFn(cmd)(transSession.SetCompliance(addr)) }, }, &cobra.Command{ Use: "setIssuer <address>", Short: "Sets the issuer to the <address>", Example: "t0ken token setIssuer 0xf01ff29dcbee147e9ca151a281bfdf136f66a45b --keystoreAddress owner", Args: cli.ChainArgs(cobra.ExactArgs(1), cli.AddressArgFunc("address", 0)), PreRun: connectTransactor, Run: func(cmd *cobra.Command, args []string) { addr := common.HexToAddress(args[0]) cli.PrintTransactionFn(cmd)(transSession.SetIssuer(addr)) }, }, &cobra.Command{ Use: "transfer <address> <quantity>", Short: "Transfers <quantity> of tokens from your address to <address>", Example: "t0ken token transfer 0xf01ff29dcbee147e9ca151a281bfdf136f66a45b 15 --keystoreAddress 0xa01a0a93716633058d69a28fbd472fd40e7c6b79", Args: cli.ChainArgs(cobra.MaximumNArgs(2), cli.AddressArgFunc("address", 0), cli.BigIntArgFunc("quantity", 1)), PreRun: connectTransactor, Run: func(cmd *cobra.Command, args []string) { addr := common.HexToAddress(args[0]) qty, _ := new(big.Int).SetString(args[1], 10) cli.PrintTransactionFn(cmd)(transSession.Transfer(addr, qty)) }, }, &cobra.Command{ Use: "transferFrom <sender> <recipient> <quantity>", Short: "Transfers <quantity> of tokens from the <sender> address to the <recipient> address", Example: "t0ken token transferFrom 0xf01ff29dcbee147e9ca151a281bfdf136f66a45b 0xf02f537578d03f6aece28f249eac19542d848f20 15 --keystoreAddress 0xa01a0a93716633058d69a28fbd472fd40e7c6b79", Args: cli.ChainArgs(cobra.MaximumNArgs(3), cli.AddressArgFunc("sender", 0), cli.AddressArgFunc("recipient", 1), cli.BigIntArgFunc("quantity", 2)), PreRun: connectTransactor, Run: func(cmd *cobra.Command, args []string) { sender := common.HexToAddress(args[0]) recipient := common.HexToAddress(args[1]) qty, _ := new(big.Int).SetString(args[2], 10) cli.PrintTransactionFn(cmd)(transSession.TransferFrom(sender, recipient, qty)) }, }, &cobra.Command{ Use: "transferOverride <sender> <recipient> <quantity>", Short: "Transfers <quantity> of tokens from the <sender> address to the <recipient> address", Example: "t0ken token transferOverride 0xf01ff29dcbee147e9ca151a281bfdf136f66a45b 0xf02f537578d03f6aece28f249eac19542d848f20 15 --keystoreAddress admin", Args: cli.ChainArgs(cobra.MaximumNArgs(3), cli.AddressArgFunc("sender", 0), cli.AddressArgFunc("recipient", 1), cli.BigIntArgFunc("quantity", 2)), PreRun: connectTransactor, Run: func(cmd *cobra.Command, args []string) { sender := common.HexToAddress(args[0]) recipient := common.HexToAddress(args[1]) qty, _ := new(big.Int).SetString(args[2], 10) cli.PrintTransactionFn(cmd)(transSession.TransferOverride(sender, recipient, qty)) }, }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.