Learning to use the demo endpoint

All asset types simply define asset specific payloads ‘AssetPayload’. The Asset Creation action is the header for all assets. TokenQty defines how many tokens there are for a particular asset.

I am trying to create a smart contract Offer but it looks like there is a problem when I submit it.
And the txid is not found in whatsonchain.com.
I am running the tokenized code I downloaded on 2019-10-23.
I have not had a chance to update to the latest release yet.
Please have a look:
dlypka@dlypka-VirtualBox:~/go/src/github.com/tokenized/smart-contract$ go run ./cmd/smartcontract/main.go build C1 ./10x-SAFE-Offer.json --tx --send
Checking Contract Offer
2020/01/12 17:58:08.313848 [Main] wallet.go:155 Info - Loaded unspent output 0.00103717 : ad4f55f9f957097251336558a0aa423aea69280bbc1db0569df47985f72f5d3e:0
2020/01/12 17:58:08.340191 [Main] wallet.go:161 Info - Loaded wallet with 1 outputs, 1 unspent, and balance of 0.00103717
2020/01/12 17:58:08.340417 [Main] wallet.go:164 Info - Wallet address : 16GgqN2sWSTZAZobNkR6uLVUUmD8LnnSPM
2020/01/12 17:58:08.340546 [Main] node.go:113 Info - Contract address : 1EJYUA1QswgV5bXeXTFWphGYBdmr48dGT
Response estimated : 491 bytes, 1546 funding
TxId: bd9e745adfadcde5a3179d917615a4b00d78ee3d0bdad6f9d46488c72435249b
Version: 1

Outpoint: 0 - ad4f55f9f957097251336558a0aa423aea69280bbc1db0569df47985f72f5d3e
Script: 473044022021d5aa55c981e383b233e32c4a0d8f89f79b67146e81caa38c346107f6b4eae702206883d273875a4b0bb1cc74d48554fe0d8866311d6f50bd0031d019ed07141eaf412103f767629f8c0b29e116242d1baa8a905029b8388ff487564c534b9119ed9ca4d3
Sequence: ffffffff


Value: 0.00004586
Script: 76a91402840d21649b944c447b03cfece617f06dc18b3788ac

Value: 0.00000000
Script: 006a02bd000e746573742e746f6b656e697a6564041a0243314cc50a1b31307856656e7475726573202d205341464520436f6e747261637410021a3a5468697320697320612073616d706c6520546f6b656e697a656420636f6e747261637420616e6420686173206e6f2

Value: 0.00098672
Script: 76a91439d01eb5a9aa39ff4ad9e4c5d931382f8793fd6988ac

LockTime: 0

2020/01/12 17:58:08.343180 [SpyNode] node.go:389 Info - Shotgunning tx : bd9e745adfadcde5a3179d917615a4b00d78ee3d0bdad6f9d46488c72435249b
2020/01/12 17:58:08.349324 [SpyNode] peers.go:94 Verbose - Loaded 4 peers
2020/01/12 17:58:13.337236 [SpyNode] node.go:106 Info - Loaded blocks to height 617151
2020/01/12 17:58:13.337521 [SpyNode] node.go:112 Info - Start block not found yet
2020/01/12 17:58:13.359471 [SpyNode] transactions.go:45 Verbose - No unconfirmed txs to load
2020/01/12 17:58:43.374718 [SpyNode] node.go:427 Verbose - Waiting for 0 untrusted nodes to finish
2020/01/12 17:58:43.374840 [SpyNode] peers.go:202 Verbose - Saving 4 peers
Action : 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”

It looks like your CLI node doesn’t have any peers.

Try running the following command and let it run for like an hour (maybe less) to find peers.

go run ./cmd/smartcontract/main.go sync --nostop

Wow thanks so much for the quick solution.
I will try it and let you know.

Yes it worked!
I found many peers
My Contract Offer tx is now on the blockchain:


1 Like

In Tokenized-smart-contract-agent-setup-final.pdf:

Transferring assets between parties

All Tokenized transfers are handled using the T1 – Transfer action which can manage transfers of all
types with multiple parties and assets.
I am going to transfer 1 of the 5 shares to an address I have created for the demo

RUN THE http:///new_contract query AGAIN?

That new contract endpoint just creates contract addresses. If you just want to transfer tokens, then you want to create another wallet address. Since our test wallet is a single key wallet it only has one address. You will have to create another wallet to transfer to another address.

  1. Run go run cmd/smartcontract/main.go gen to create a new key/address.
  2. Create a new directory to run the new wallet from.
  3. Create a new config file that points to the new directory and contains your new key.
  4. source the new config and run go run cmd/smartcontract/main.go sync to sync it.
  5. Then source the previous config, create a transfer json with the new address in it as a receiver, and build a transfer action and tx from it.

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).


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?


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:
dlypka@dlypka-VirtualBox:~/go/src/github.com/tokenized/smart-contract$ go run ./cmd/smartcontract/main.go parse 006a02bd000e746573742e746f6b656e697a6564041a0243314cc50a1b31307856656e7475726573202d205341464520436f6e74726163741

I got this hex from this transaction:

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:
dlypka@dlypka-VirtualBox:~/go/src/github.com/tokenized/smart-contract$ ~/go/bin/smartcontract parse 006a02bd000e746573742e746f6b656e697a6564041a0243314cc50a1b31307856656e7475726573202d205341464520436f6e747261637410021a3a54686

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:
dlypka@dlypka-VirtualBox:~/go/src/github.com/tokenized/smart-contract$ go run ./cmd/smartcontract/main.go parse


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?