Learning to use the demo endpoint

The varchar such as here in the Description field can be up to the 100K size limit of OP_RETURN, right?

Share - Common

Common stock represents ownership interests in companies.

Field Type Description
TransferLockout Timestamp A period of time where the asset is unable to be transferred. After the transfer lockout period, the assets can be transferred. Example: 11/4/2019 18:00:00
Ticker fixedchar(5) Ticker symbol assigned by exchanges to represent the asset. Example: AAPL
ISIN fixedchar(12) International Securities Identification Number Example: US0004026250
Description varchar Example: Class C

The primitive types are explained in the link below. That definition should specify which range of variable size is used for that field, but we must have accidentally removed that from the website. From the source yaml, that field is defined as a “small” varchar (so up to 65,535 bytes).

https://tokenized.com/docs/protocol/intro#primitive-types

I assume that a small varchar is up to 65K because of the OP_RETURN size allowing that, since it is now 100K.

My next question, is there any field size in the smart contracts that is a larger varchar going up to at least the 100K? Actually 65K is still great but for curiosity I would like to know if 100K is achievable in any of the smart contract fields.

The sizes of variable size values are based on powers of 2 based on byte sizes. 2 to the power of tiny 8 bits (256), small 16 bits (65K), medium 32 bits (4.2 billion), and large 64 bits (very large). They aren’t really based on Bitcoin limits as we expect them to all be removed. Though you need to make sure your transactions still stay within those limits until then.

There are some fields that use larger sizes currently. One example is the BodyOfAgreement field in a ContractOffer that is varbin(medium) which is up to 4.2 GB.

When I look at my Contract Offer Text in WhatsOnChain, the white space is not all blanks. It is various characters. Any idea why the white space is not as expected?

image

That is actually binary data interpreted as ASCII text. The OP_RETURN has a very specific binary format that has to be interpreted by the correct software. I am sure the block explorers will add that ability before too long, but not yet.

You can display the hex on the website and copy/paste into the parse command on the smart contract CLI to see the data in a more friendly format.

Thanks for the info.
Well when I try it it do not get any output:
[email protected]:~/go/src/github.com/tokenized/smart-contract$ go run ./cmd/smartcontract/main.go parse 006a02bd000e746573742e746f6b656e697a6564041a0243314cc50a1b31307856656e7475726573202d205341464520436f6e74726163741
0021a3a5468697320697320612073616d706c6520546f6b656e697a656420636f6e747261637420616e6420686173206e6f207265616c2076616c75652e222953696d706c652041677265656d656e7420666f7220467574757265204571756974792028534146452952220a0c31307820
56656e7475726573120149720f0805120b4461766964204c79706b61b00101c20115207259fb40c57acfc817d3a5e046fc83b9e1387cde
[email protected]:~/go/src/github.com/tokenized/smart-contract$

I got this hex from this transaction:
bd9e745adfadcde5a3179d917615a4b00d78ee3d0bdad6f9d46488c72435249b

parse is not giving me any output to the console no matter what input I try.

Does it write to somewhere else, not to the console?
Or is there some issue that make it kick out?

It looks like there are line breaks in your hex, so it is probably just failing to parse it. It isn’t really user friendly enough to give errors. :smile:

When I run this it gives the output below

go run cmd/smartcontract/main.go parse 006a02bd000e746573742e746f6b656e697a6564041a0243314cc50a1b31307856656e7475726573202d205341464520436f6e747261637410021a3a5468697320697320612073616d706c6520546f6b656e697a656420636f6e747261637420616e6420686173206e6f207265616c2076616c75652e222953696d706c652041677265656d656e7420666f7220467574757265204571756974792028534146452952220a0c3130782056656e7475726573120149720f0805120b4461766964204c79706b61b00101c20115207259fb40c57acfc817d3a5e046fc83b9e1387cde

Uses Test Protocol Signature
Action type : C1

{
    "ContractName": "10xVentures - SAFE Contract",
    "BodyOfAgreementType": 2,
    "BodyOfAgreement": "5468697320697320612073616d706c6520546f6b656e697a656420636f6e747261637420616e6420686173206e6f207265616c2076616c75652e",
    "ContractType": "Simple Agreement for Future Equity (SAFE)",
    "Issuer": {
        "Name": "10x Ventures",
        "Type": "I",
        "Management": [
            {
                "Type": 5,
                "Name": "David Lypka"
            }
        ]
    },
    "HolderProposal": true,
    "MasterAddress": "207259fb40c57acfc817d3a5e046fc83b9e1387cde"
}

So I tried to replicate your successful run but still no output:
[email protected]:~/go/src/github.com/tokenized/smart-contract$ ~/go/bin/smartcontract parse 006a02bd000e746573742e746f6b656e697a6564041a0243314cc50a1b31307856656e7475726573202d205341464520436f6e747261637410021a3a54686
97320697320612073616d706c6520546f6b656e697a656420636f6e747261637420616e6420686173206e6f207265616c2076616c75652e222953696d706c652041677265656d656e7420666f7220467574757265204571756974792028534146452952220a0c3130782056656e747572
6573120149720f0805120b4461766964204c79706b61b00101c20115207259fb40c57acfc817d3a5e046fc83b9e1387cde
[email protected]:~/go/src/github.com/tokenized/smart-contract$

Do I need to update to the latest code? If so, can I just overcopy all the .go files? or do I have to rebuild something?

I don’t think our build process updates “~/go/bin/”. Run make dist and then dist/smartcontract parse or go run cmd/smartcontract/main.go parse

Are you talking about steps to do if I overcopy the .go files with the latest code?

And did you run the script I sent you? Did it output the correct result?

I also tried to debug cmd_parse.go by adding print statements.
But now it does not run anymore even when I remove my print statements.
I get this error output:
[email protected]:~/go/src/github.com/tokenized/smart-contract$ go run ./cmd/smartcontract/main.go parse

github.com/tokenized/smart-contract/cmd/smartcontract/cmd

cmd/smartcontract/cmd/cmd_parse2.go:20:5: cmdParse redeclared in this block
previous declaration at cmd/smartcontract/cmd/cmd_parse.go:20:5
cmd/smartcontract/cmd/cmd_parse2.go:57:6: parseTx redeclared in this block
previous declaration at cmd/smartcontract/cmd/cmd_parse.go:53:59
cmd/smartcontract/cmd/cmd_parse2.go:77:6: parseScript redeclared in this block
previous declaration at cmd/smartcontract/cmd/cmd_parse.go:73:64
cmd/smartcontract/cmd/cmd_parse_Crash.go:20:5: cmdParse redeclared in this block
previous declaration at cmd/smartcontract/cmd/cmd_parse2.go:20:5
cmd/smartcontract/cmd/cmd_parse_Crash.go:57:6: parseTx redeclared in this block
previous declaration at cmd/smartcontract/cmd/cmd_parse2.go:57:59
cmd/smartcontract/cmd/cmd_parse_Crash.go:77:6: parseScript redeclared in this block
previous declaration at cmd/smartcontract/cmd/cmd_parse2.go:77:64

Can I fix it by running make again? What should my current directory be in order to run that make again?

No, I think the binary executable you were executing is old and doesn’t update from our build process.

The script you posted is fine minus that and the line breaks, which I assume are a result of you pasting into the forum.

Just git pull to make sure you have the latest code in smart-contract and specification, then use go run cmd/smartcontract/main.go parse

OK I applied the latest code as you instructed and now the parse command works. Thanks.
[email protected]:~/go/src/github.com/tokenized/smart-contract$ go run ./cmd/smartcontract/main.go parse
go: downloading github.com/tokenized/specification v0.2.2-0.20191219061451-ecd0fc17c3ca
go: downloading github.com/pkg/errors v0.8.1
go: extracting github.com/pkg/errors v0.8.1
:
:
go: finding github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f
go: finding github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd
go: finding github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792
Enter hex to decode: 006a02bd000e746573742e746f6b656e697a6564041a0243314cc50a1b31307856656e7475726573202d205341464520436f6e747261637410021a3a5468697320697320612073616d706c6520546f6b656e697a656420636f6e747261637420616e6420686173206e6f207265616c2076616c75652e222953696d706c652041677265656d656e7420666f7220467574757265204571756974792028534146452952220a0c3130782056656e7475726573120149720f0805120b4461766964204c79706b61b00101c20115207259fb40c57acfc817d3a5e046fc83b9e1387cde

Uses Test Protocol Signature
Action type : C1

{
    "ContractName": "10xVentures - SAFE Contract",
    "BodyOfAgreementType": 2,
    "BodyOfAgreement": "5468697320697320612073616d706c6520546f6b656e697a656420636f6e747261637420616e6420686173206e6f207265616c2076616c75652e",
    "ContractType": "Simple Agreement for Future Equity (SAFE)",
    "Issuer": {
        "Name": "10x Ventures",
        "Type": "I",
        "Management": [
            {
                "Type": 5,
                "Name": "David Lypka"
            }
        ]
    },
    "HolderProposal": true,
    "MasterAddress": "207259fb40c57acfc817d3a5e046fc83b9e1387cde"
}

[email protected]:~/go/src/github.com/tokenized/smart-contract$

2 Likes

Now I am trying to setup my own BSV Node to resume following the Quick Start Examples.
For using the node only for Tokenized purposes, it an pruned node adequate?
I am thinking of only loading blocks from when I started using MoneyButton a few months ago.
Is that enough for the smart contracts to work?

Yes, you only need to load blocks that have transactions related to your wallet and contract.

In dev.env:

What is

The address to pay fees to

export FEE_ADDRESS=16GgqN2sWSTZAZobNkR6uLVUUmD8LnnSPM

Is it supposed to be my contract wallet address?

It should be a separate address. It is the address that tokenized request fees get put into. Like those specified in the ContractFee field in the ContractOffer.

I have my own BSV 1.01 Full-node syncd and running on my laptop.
I am now running smartcontractd locally using
source ./conf/dev.env && make run
Now I am confused what should I put for the CLIENT_CONTRACT_ADDRESS in the .env when it is local?
I thought the endpoint supplied on your server was smartcontractd running on your side.
for example: {“address”:“1EJYUA1QswgV5bXeXTFWphGYBdmr48dGT”,“contract_fee”:2000}

What is the contract address from my local smartcontractd instance?