Learning to use the demo endpoint

If a Smart Contract is funded with BSV, how to mitigate the large fluctuations in the BSV exchange rate? Is the Amleh token the recommended solution in the longer term? In the short term, is it practical to immediately convert from BSV to some stable coin at time of contract funding?

I am not clear where is the data field about the number of tokens a person owns stored?
How to query for it?
I only see these fields documented for Share - Common:

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

Asset Creation

This action creates an asset in response to the administration’s instructions in the Definition Action.

Action Code A2

Field Type Description
AssetCode AssetCode A unique code that is used to identify the asset. It is generated by hashing the contract public key hash and the asset index. SHA256(contract PKH + asset index) Cannot be changed by the administration, operator or smart contract.
AssetIndex uint(8) The index of the asset within the contract. First asset is zero, second is one. Used to derive the asset code. Example: 0
AssetPermissions varbin(small) A set of permission objects containing switches and field references that define the permissions for modifying this asset. See the Permission documentation for more detail.
TransfersPermitted bool Set to true if transfers are permitted between two parties, otherwise set to false to prevent peer-to-peer transfers. Example: 1
TradeRestrictions Polity[small] If specified, the asset can only be traded within the specified trade restriction zone. For example, AUS would restrict to Australian residents only.
EnforcementOrdersPermitted bool Set to true if the administration is permitted to make enforcement orders on user tokens and balances, otherwise set to false to disable this feature. Example: 1
VotingRights bool When false holders of this asset will not be able to vote for tokens of this asset even on voting systems in which vote multiplers are not permitted. Example: true
VoteMultiplier uint(1) Multiplies a vote by the specified integer. Where 1 token is equal to 1 vote with a 1 for vote multipler (normal), 1 token = 3 votes with a multiplier of 3, for example. If zero, then holders of this asset don’t get any votes for their tokens. Example: 3
AdministrationProposal bool Set to true if the administration is permitted to make proposals outside of the smart contract scope. General Governance Example: true
HolderProposal bool Set to true if a holder is permitted to make proposals outside of the smart contract scope. Example: true
AssetModificationGovernance uint(1) Supported values: 1 - Contract-wide Asset Governance. 0 - Asset-wide Asset Governance. If a referendum or initiative is used to propose a modification to a subfield controlled by the asset permissions, then the vote will either be a contract-wide vote (all assets vote on the referendum/initiative) or an asset-wide vote (only this asset votes on the referendum/initiative) depending on the value in this subfield. The voting system specifies the voting rules. Example: 1
TokenQty uint(8) The number of tokens to issue with this asset. Set to greater than zero for fungible tokens. If the value is 1 then it becomes a non-fungible token, where the contract would have many assets. Set to 0 to represent a placeholder asset, where tokens are to be issued later, or to represent a decomissioned asset where all tokens have been revoked. Example: 1000000
AssetType AssetType A code representing the type of asset and the structure of the payload.
AssetPayload varbin(small) A custom payload that contains meta data about this asset. Payload structure and length is dependent on the asset type chosen. See asset documentation for more details.
AssetRevision uint(4) A counter for the number of times this asset has been revised using a modification action. Example: 456789
Timestamp Timestamp Timestamp in nanoseconds of when the smart contract created the action. Cannot be changed by the administration or operator. Smart contract controls.

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
Inputs:

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

Outputs:

Value: 0.00004586
Script: 76a91402840d21649b944c447b03cfece617f06dc18b3788ac

Value: 0.00000000
Script: 006a02bd000e746573742e746f6b656e697a6564041a0243314cc50a1b31307856656e7475726573202d205341464520436f6e747261637410021a3a5468697320697320612073616d706c6520546f6b656e697a656420636f6e747261637420616e6420686173206e6f2
07265616c2076616c75652e222953696d706c652041677265656d656e7420666f7220467574757265204571756974792028534146452952220a0c3130782056656e7475726573120149720f0805120b4461766964204c79706b61b00101c20115207259fb40c57acfc817d3a5e046fc83
b9e1387cde

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”
}
dlypka@dlypka-VirtualBox:~/go/src/github.com/tokenized/smart-contract$

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:

Thanks.

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.
https://tokenized.com/docs/protocol/actions#action-transfer
I am going to transfer 1 of the 5 shares to an address I have created for the demo

HOW EXACTLY WAS THE ADDRESS CREATED?
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).

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:
dlypka@dlypka-VirtualBox:~/go/src/github.com/tokenized/smart-contract$ go run ./cmd/smartcontract/main.go parse 006a02bd000e746573742e746f6b656e697a6564041a0243314cc50a1b31307856656e7475726573202d205341464520436f6e74726163741
0021a3a5468697320697320612073616d706c6520546f6b656e697a656420636f6e747261637420616e6420686173206e6f207265616c2076616c75652e222953696d706c652041677265656d656e7420666f7220467574757265204571756974792028534146452952220a0c31307820
56656e7475726573120149720f0805120b4461766964204c79706b61b00101c20115207259fb40c57acfc817d3a5e046fc83b9e1387cde
dlypka@dlypka-VirtualBox:~/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:
dlypka@dlypka-VirtualBox:~/go/src/github.com/tokenized/smart-contract$ ~/go/bin/smartcontract parse 006a02bd000e746573742e746f6b656e697a6564041a0243314cc50a1b31307856656e7475726573202d205341464520436f6e747261637410021a3a54686
97320697320612073616d706c6520546f6b656e697a656420636f6e747261637420616e6420686173206e6f207265616c2076616c75652e222953696d706c652041677265656d656e7420666f7220467574757265204571756974792028534146452952220a0c3130782056656e747572
6573120149720f0805120b4461766964204c79706b61b00101c20115207259fb40c57acfc817d3a5e046fc83b9e1387cde
dlypka@dlypka-VirtualBox:~/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?