TinyURL for this file: https://tinyurl.com/tezos-sfbw19
brew tap tqtezos/homebrew-tq https://github.com/tqtezos/homebrew-tq.git
brew install tezos
brew install lorentz-contract-param
brew install lorentz-contracts-saleInstall Ruby
To ensure that Ruby is installed, run which ruby:
$ which ruby
/usr/bin/rubyThe Ruby tools used in this tutorial were tested on:
$ ruby -v $
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]git clone https://github.com/tqtezos/lorentz-contracts-sale.git
cd originations/taco_sale
rm taco_sale_user.originations.yamlSend an account request to [email protected]
with subject SBFW_NEW_ACCOUNT.
You will receive a line that looks like:
bobs-key-100,edpkunrCtFEkdARBY6tDEAxvpNKGcw2FCgWTX6T5AQNoJaqX6JE9dh,tz1Suah9bipLFo3jNZWwhL7bR9J3DVmnMjvh,unencrypted:edsk3RFfvfE3qxLELeUxzTz1DHfb6NHTTscLs45HnvUcmuisLwTEE5
You will need to add your keys to three files in ~/tezos-client
for the client to recognize your account:
~/.tezos-client/public_key_hashes
[ { "name": "bob", "value": "tz1bDC.." } ]
~/.tezos-client/public_keys
[ { "name": "bob",
"value":
{ "locator":
"unencrypted:edpkuPT..",
"key": "edpkuPT.." } } ]
~/.tezos-client/secret_keys
[ { "name": "bob",
"value":
"unencrypted:edsk4Bi.." } ]
Edit taco_sale_user.yaml to use your username in the config > user-base-config > user_address field:
config:
user-base-config: &user-base-config
tezos_client_path:
"tezos-client -A ec2-18-190-24-202.us-east-2.compute.amazonaws.com -P 20000"
user_address:
tz1[YOUR_ADDRESS_HERE]
param_path: '.'
stack_path: nullOptional:
- Replace
Bobwith your name (without spaces) - Modify the minted amount:
- run: &mint-token
alias: MintTokenBob_Bob_100
config: $user-base-config
contract: $TokenBob
command: lorentz-contract-param ManagedLedgerBabylon-mint
parameters:
to: $Bob
value: [AMOUNT_TO_MINT]
burn_cap: '0.074'To originate, run:
../../lorentz-contract-originate.rb taco_sale_user.yaml
It should fail when it reaches SaleToken17_TokenTokenBob_1_1 (we'll get to that in a bit).
If it succeeds in originating your contract taco_sale_user.originated.yaml
should contain the address of your new token!
# taco_sale_user.originated.yaml
originated:
TokenBob:
address: KT1DFXkKHnbDQwv4PXbk2VDygeBfop6QN55h
config: "$user-base-config"Send the whole taco_sale_user.originated.yaml file to [email protected]
with subject SBFW_NEW_TOKEN.
I'll then originate a randomly selected sale that will allow you to trade up to Token1,
the taco stablecoin.
You'll be able to trade up to 100 of your tokens 1:1 for a randomly selected leaf token in the
binary tree.
Once your entry sale-contract is originated, I'll send you a user entry
for the do field in your taco_sale_user.yaml file.
It'll look something like this:
- user:
name: SaleToken17_TokenTokenBob_1_1
address: KT1UvFrCuk8oJqbhJQVGPPfUqKo4FBH6okwrNote: feel free to rename it, as long as you reference the new name when purchasing tokens
Replace the example SaleToken user in your taco_sale_user.yaml
(your token won't be authorized to purchase from the one in the example):
# taco_sale_user.yaml
do:
..
- user:
name: SaleToken17_TokenBob_1_1
address: KT1UvFrCuk8oJqbhJQVGPPfUqKo4FBH6okwrIf the rest of the taco_sale_user.yaml is unmodified,
It will allow the sale contract to spend all of its tokens:
- run: &approve
alias: SaleToken17_TokenBob_1_1_100
config: $user-base-config
contract: $TokenBob
command: lorentz-contract-param ManagedLedgerBabylon-approve
parameters:
spender: $SaleToken17_TokenBob_1_1
value: 100
burn_cap: '0.031'And then purchase a single token from the sale contract:
- run: &purchase
alias: PurchaseToken17
config: $user-sale-config
contract: $SaleToken17_TokenBob_1_1
command: "lorentz-contracts-sale purchase"
parameters:
held-price: "1"
wanted-price: "1"
burn_cap: "0.148"Finally, it will originate two contracts to store how many tokens you have in your original contract as well as in the contract you just bought tokens from:
- originate: &originate-nat-storage
alias: BobPostSaleBalanceToken17
config: $user-base-config
command: "lorentz-contract print --name NatStorageContract"
storage_command: "ruby -e 'puts ARGV[1]' -- "
initial_storage:
initial: "0"
burn_cap: "0.295"
- originate:
<<: *originate-nat-storage
alias: BobPostSaleBalanceTokenBob
config: $user-base-config - run: &get-balance
alias: BobPostSaleGetBalanceToken17
config: $user-base-config
contract: $Token17
command: "lorentz-contract-param ManagedLedgerBabylon-getBalance"
parameters:
account: $Bob
callback-contract: $BobPostSaleBalanceToken17
burn_cap: "0.000001"
- run:
<<: *get-balance
alias: BobPostSaleGetBalanceTokenBob
contract: $TokenBob
parameters:
callback-contract: $BobPostSaleBalanceTokenBobThere's an example origination of a sale contract commented out
at the end of taco_sale_user.yaml, which you can use to offer your
own sales:
- originate: &originate-sale
alias: SaleTokenBob_Token16
config: $user-sale-config
command: lorentz-contracts-sale print
storage_command: lorentz-contracts-sale init
initial_storage:
admin: $Bob
held: $TokenBob
wallet: $Bob
wanted: $Token16
held-price: '1'
wanted-price: '2'
burn_cap: '1.749'Note: you'll need to approve the new sale contract to spend how ever many
tokens you're willing to sell. See do > run: &approve in taco_sale_user.yaml.
Until you approve any tokens, it will be able to spend zero of your tokens, and so
it will be an offer for zero tokens at the price you set.