Classified submissions in South Africa|I will do 12 south africa local high da classifieds, $10 = 12 South African Local classifieds 3 Days Delivery


 
About This Item
 
Classified submissions is one of techniques in S.E.O off-page strategy which is used for promote the business or service in South African search engines like Google with the help of local classified posting, this is the most simple and easy way to get rank of your keyword on local search engine, also helpful to fetch native traffic on your site within few days.
 
Continue Read »

 
About This Item
 
Classified submissions is one of techniques in S.E.O off-page strategy which is used for promote the business or service in South African search engines like Google with the help of local classified posting, this is the most simple and easy way to get rank of your keyword on local search engine, also helpful to fetch native traffic on your site within few days.
  Collapse Read »

I will do local citations service for 15 south africa local directories, $5 = 7 Days Delivery


 
 
I will submit your Business, Company or Website Detail to 15 South Africa Local Directories, Manually.

Minimum Order Requirements:

Company Name
Complete Address
Business Phone
You Can Include: Logo, Website/URL, Business E-Mail, Fax, Mobile, Toll Free Number, Contact Person, Description, Service or Product, Keywords/Tags, Year Founded, Number of Employees, Business Hrs/Day.

Please Note:

If Order Requirements is ready, then Order.


We are accepting Only South Africa Business Listings.
You can provide us your favorite sites, we will use.
We will add photo to your listing (only if allowed in free listing option.
We are not accepting any kind of adult entertainment/porn related orders.
If you have an existing listing for some local directories please forward that also as to avoid duplicate listing.
After completed work I will give you complete detailed report.
Friendly Customer Support (asks us anything/anytime!)
Continue Read »

 
 
I will submit your Business, Company or Website Detail to 15 South Africa Local Directories, Manually.

Minimum Order Requirements:

Company Name
Complete Address
Business Phone
You Can Include: Logo, Website/URL, Business E-Mail, Fax, Mobile, Toll Free Number, Contact Person, Description, Service or Product, Keywords/Tags, Year Founded, Number of Employees, Business Hrs/Day.

Please Note:

If Order Requirements is ready, then Order.


We are accepting Only South Africa Business Listings.
You can provide us your favorite sites, we will use.
We will add photo to your listing (only if allowed in free listing option.
We are not accepting any kind of adult entertainment/porn related orders.
If you have an existing listing for some local directories please forward that also as to avoid duplicate listing.
After completed work I will give you complete detailed report.
Friendly Customer Support (asks us anything/anytime!) Collapse Read »

south africa web directory submissions manually|I will do 31 south africa web directory submissions manually, $5 = 31 South Africa directory 2 Days Delivery


 
 
About This Item
 
South Africa Directory of major Regional search engines and directories to free submit, announce your web site with the add url links and text , I will submit your business in top 31 South African web directories, All submission done manually, provide report with some instant approved directory back link  
 
Continue Read »

 
 
About This Item
 
South Africa Directory of major Regional search engines and directories to free submit, announce your web site with the add url links and text , I will submit your business in top 31 South African web directories, All submission done manually, provide report with some instant approved directory back link  
  Collapse Read »

I will create 60 best south africa local citations, $10 = 100% Manual Work High Quality Citations Provide you detailed report with all the logins


 
 
We are team of local citations expert and has 8 years experience.

I will submit your business in high quality South Africa local citations sites.

I will do high quality work to improve your local search results.

Will provide you the detailed report with all the submissions, activation's and logins.
Continue Read »

 
 
We are team of local citations expert and has 8 years experience.

I will submit your business in high quality South Africa local citations sites.

I will do high quality work to improve your local search results.

Will provide you the detailed report with all the submissions, activation's and logins. Collapse Read »

I will do 55 south africa local high da, tf citations, $10 = 45 ZA Citation Creation 3 Days DeliveryUnlimited Revisions


 
 
Local citation listing service is the best way to gain visibility and backlinks in local search engine, if you are business in South Africa and you are not thinking about local citation building, you are omitting an important measure to success of your company, basically the term local citation is related to boost your local Google ranking. With this service I will do best appropriate niche local citations with the popular South African local high quality citation sites. Having steady and all display exactly the same info about your website help you to improve your ranking in local search.
 
 
Continue Read »

 
 
Local citation listing service is the best way to gain visibility and backlinks in local search engine, if you are business in South Africa and you are not thinking about local citation building, you are omitting an important measure to success of your company, basically the term local citation is related to boost your local Google ranking. With this service I will do best appropriate niche local citations with the popular South African local high quality citation sites. Having steady and all display exactly the same info about your website help you to improve your ranking in local search.
 
  Collapse Read »

I will do south africa local citation, $15 = 30 Local Directories/Citation with 100% live business links 2 Days Delivery Listing Submissions


 
 
Hi,

I list your Business in Quality Local South Africa Business Directories with 100% Manually, that help you to rank in Google.

Features
100% Manual Work, NAP Constant for ALL Citations. 
Duplicate will check for every listing
100% Customer Satisfaction
Niche-specific Directory Sites
Full Excel Report With Login Details.
Quick response
Why are you buy this?
* Local Listings can appear on the 1st page of Local Google search results.
* Targets local consumers to buy a certain product or service.
* Organic traffic driven to your website.
* It will give you qualified leads, since people from your area will be reached to you.
* These listings help you to beat your competitor.

Order right now!!
100% Satisfaction with money back Guarantee.
Continue Read »

 
 
Hi,

I list your Business in Quality Local South Africa Business Directories with 100% Manually, that help you to rank in Google.

Features
100% Manual Work, NAP Constant for ALL Citations. 
Duplicate will check for every listing
100% Customer Satisfaction
Niche-specific Directory Sites
Full Excel Report With Login Details.
Quick response
Why are you buy this?
* Local Listings can appear on the 1st page of Local Google search results.
* Targets local consumers to buy a certain product or service.
* Organic traffic driven to your website.
* It will give you qualified leads, since people from your area will be reached to you.
* These listings help you to beat your competitor.

Order right now!!
100% Satisfaction with money back Guarantee. Collapse Read »

I will manually boost your business in 35 south africa directory, $5 =35 Africa directory 2 Days Delivery

 

 
Have your website submitted manually to the best set of quality South African directories available on the web. Get top quality back links from these lists of free directories. Many well established website directories can take months to review your submission requests, and most of these established web directories have strict listing. Friendly link directory. Find the best human edited link index sorted by topic and category. Submit links for free.
Continue Read »
 

 
Have your website submitted manually to the best set of quality South African directories available on the web. Get top quality back links from these lists of free directories. Many well established website directories can take months to review your submission requests, and most of these established web directories have strict listing. Friendly link directory. Find the best human edited link index sorted by topic and category. Submit links for free. Collapse Read »

I will do 52 south africa da web directory, $10 = 48 Local South African Directory Submissions 3 Days DeliveryUnlimited Revisions


 
 
About This service
 
Local South Africa web directory are carrying the equivalent value of high quality backlinks in White-hat S.E.O.  it’s one of the best ways to boost your rankings in local search engines, getting your data accurately submitted in domain authority sites, can help you scale the allocation of your business information across thousands of local customers.
 
Continue Read »

 
 
About This service
 
Local South Africa web directory are carrying the equivalent value of high quality backlinks in White-hat S.E.O.  it’s one of the best ways to boost your rankings in local search engines, getting your data accurately submitted in domain authority sites, can help you scale the allocation of your business information across thousands of local customers.
  Collapse Read »

I will publish guest post on south africa today, $40 = I will write and publish on SouthAfricaToday DA55 multi niche blog 4 Days Delivery

 

 
About This item
 
In this item, I am offering a guest post on SouthAfricaToday  DA 55 High Authority Blog. We do permanent Guest post.

Why Me?

500  Words Article
Do-follow (1 anchor text per article)
100% Indexation Guarantee 
Permanent post and fast delivery
About Blog

Having 10k Daily Visitors from USA
PA - 51 DA  - 53
Old Authority News Blog
Note:

Do contact me before placing the order and discuss the details
No Adult(Porn), Gambling, Dating, Casino content will be published
100% SATISFACTION GUARANTEED or You will get 100% Refund without any question.

If you're unsure if your site is a good fit, just message me before ordering!
 
Continue Read »
 

 
About This item
 
In this item, I am offering a guest post on SouthAfricaToday  DA 55 High Authority Blog. We do permanent Guest post.

Why Me?

500  Words Article
Do-follow (1 anchor text per article)
100% Indexation Guarantee 
Permanent post and fast delivery
About Blog

Having 10k Daily Visitors from USA
PA - 51 DA  - 53
Old Authority News Blog
Note:

Do contact me before placing the order and discuss the details
No Adult(Porn), Gambling, Dating, Casino content will be published
100% SATISFACTION GUARANTEED or You will get 100% Refund without any question.

If you're unsure if your site is a good fit, just message me before ordering!
  Collapse Read »

I will give you information on south africa, $5 = I will provide you with information on South Africa! * Fun Facts * Geographical * Historical


 
About This item:
 
I will provide you with information & images from South Africa.

Fun Facts
History
Geography
Political
Cultural
Education
Do you need a postcard?
Please send me a message with what info you require before placing an order to make sure that I am able to assist.

Pricing is from $5 per hour.
 
 
Continue Read »

 
About This item:
 
I will provide you with information & images from South Africa.

Fun Facts
History
Geography
Political
Cultural
Education
Do you need a postcard?
Please send me a message with what info you require before placing an order to make sure that I am able to assist.

Pricing is from $5 per hour.
 
  Collapse Read »

I will edit your documentary, corporate or fiction short film, $140 5 min movie from up to 30 min of footage 4 Days Delivery1 Revision


 
 
About This Item
 
You have a short film you need edited (fiction/documentary/corporate).

I have the eye, the ear and the video editing software you need to make it happen.

Let's work together to find the heart of your story and bring it to life.

What you get from me:

A professionally edited, engaging short film to share with the world (MP4 file in 720p HD / 1080p Full HD / 4K Ultra HD)

ADDITIONAL (Standard / Premium gigs only): 
Basic sound editing

Basic colour correction
Up to 3 export formats 

What I need from you:

Pre-selected and labeled footage (if your raw footage exceeds the Gig limits, try selecting the 2/3 best takes from each camera set up)
Labeled audio files, where applicable
Any relevant music or sound FX files 
Script story outline
Specific output requirements (if applicable)
Visual references (if applicable)
End credits content (if applicable)
Continue Read »

 
 
About This Item
 
You have a short film you need edited (fiction/documentary/corporate).

I have the eye, the ear and the video editing software you need to make it happen.

Let's work together to find the heart of your story and bring it to life.

What you get from me:

A professionally edited, engaging short film to share with the world (MP4 file in 720p HD / 1080p Full HD / 4K Ultra HD)

ADDITIONAL (Standard / Premium gigs only): 
Basic sound editing

Basic colour correction
Up to 3 export formats 

What I need from you:

Pre-selected and labeled footage (if your raw footage exceeds the Gig limits, try selecting the 2/3 best takes from each camera set up)
Labeled audio files, where applicable
Any relevant music or sound FX files 
Script story outline
Specific output requirements (if applicable)
Visual references (if applicable)
End credits content (if applicable) Collapse Read »

I will write a travel article for your blog, $50= 3 Days Delivery +Up to 800 Words +Up to 3 Focus Words

 
 
 
 
I created my own blog where I am writing my adventures and my good tips. 

During my last year internship in the travel agency Ekima Afrika Travel in Cape Town , South Africa, I was helping the community manager.

I wrote some articles for their blogs. The articles were about trips that they were selling, some volunteer actions that the travel agency made, articles about some countries such as Botswana or Namibia. 

I am also really active on the social media, and during my stay in Cape Town, I worked for the famous CapeTown magazine. I was taking care of their Instagram page. 
Continue Read »
 
 
 
 
I created my own blog where I am writing my adventures and my good tips. 

During my last year internship in the travel agency Ekima Afrika Travel in Cape Town , South Africa, I was helping the community manager.

I wrote some articles for their blogs. The articles were about trips that they were selling, some volunteer actions that the travel agency made, articles about some countries such as Botswana or Namibia. 

I am also really active on the social media, and during my stay in Cape Town, I worked for the famous CapeTown magazine. I was taking care of their Instagram page.  Collapse Read »

I will write SEO optimized and catchy listicles about africa, $15 Includes 5-7 sentences for each item on the list. 2 Days Delivery1 Revision


 
 
A listicle is perhaps the type of article that captures the reader the most. It is more organized, easier-to-grasp and to the point. Many blog readers quickly get lost and bored in long paragraphs of explanations, which makes their engagement short-lived.

As a travel blogger myself, listicles have always been my favorite articles. Not only are they fun to read but they are also just as fun to write. 

I can provide articles in the form of listicles about Africa, especially South Africa and Cape Town where I currently reside. This is the fastest way for readers curious about African countries to get the information they need.
Continue Read »

 
 
A listicle is perhaps the type of article that captures the reader the most. It is more organized, easier-to-grasp and to the point. Many blog readers quickly get lost and bored in long paragraphs of explanations, which makes their engagement short-lived.

As a travel blogger myself, listicles have always been my favorite articles. Not only are they fun to read but they are also just as fun to write. 

I can provide articles in the form of listicles about Africa, especially South Africa and Cape Town where I currently reside. This is the fastest way for readers curious about African countries to get the information they need. Collapse Read »

I will send you a fun filled list of activities to do in Cape Town SA, $5 = 1 Day Delivery

 

 
Fun capital of South Africa.this list is a guide and combination of living and working in the media industry in Cape Town.A human connection with what is happening in this fun loving country now.time of ad.19degree sunshine 15 km from muizenberg. google it
Continue Read »
 

 
Fun capital of South Africa.this list is a guide and combination of living and working in the media industry in Cape Town.A human connection with what is happening in this fun loving country now.time of ad.19degree sunshine 15 km from muizenberg. google it Collapse Read »

I will write post about cape town or south africa, $10 = 500 word blog post Research

 
 

 
 Experienced Published writer based in Cape Town.  
I will write a travel realted blog post or article about one of the must visit places on earth. 
Tourists
Beaches
Mountains
 
 
Continue Read »
 
 

 
 Experienced Published writer based in Cape Town.  
I will write a travel realted blog post or article about one of the must visit places on earth. 
Tourists
Beaches
Mountains
 
  Collapse Read »

I will write any script or story you want, $20 = Creative, business and marketing, educational --fiction and non-fiction. 7 Days Delivery3 Revisions

 

 
 
My professional background encompasses the arts, business, ecology, tourism and education.It includes a BA with an English major; business, marketing and copy-editing qualifications; forty years in the theatre and film industry as actor, writer and teacher. For eighteen of those years I also managed a performing arts higher education institution and production company. 

Somewhere along the line I also managed to run a successful guest lodge and in the field for two environmental service agencies. 

I live in Cape Town now, where I was born. I lived for two decades in the Netherlands and  worked briefly in the UK, Sweden and New York. 

In all of these environments, I have relied heavily, if not entirely, on my research and writing skills.

So, bring it on; this writer is ready for anything. 
Continue Read »
 

 
 
My professional background encompasses the arts, business, ecology, tourism and education.It includes a BA with an English major; business, marketing and copy-editing qualifications; forty years in the theatre and film industry as actor, writer and teacher. For eighteen of those years I also managed a performing arts higher education institution and production company. 

Somewhere along the line I also managed to run a successful guest lodge and in the field for two environmental service agencies. 

I live in Cape Town now, where I was born. I lived for two decades in the Netherlands and  worked briefly in the UK, Sweden and New York. 

In all of these environments, I have relied heavily, if not entirely, on my research and writing skills.

So, bring it on; this writer is ready for anything.  Collapse Read »

personal driver in cape town|I will be your personal driver in cape town and surrounds, $20 = I will drive you safely from point A to Point B 1 Day Delivery


 
 
About This Item:
 
I will supply the vehicle to collect you any ware in Western Cape and deliver you safely.
We need to discuss your requirements beforehand to work out a price as there are different scenarios.

1. Pickup and deliver to venue
2. Pickup, wait at end and return you safely
3. Custom request. Tour, Sight seeing, adventure, Sleep out possible, Bookings all your needs will be catered for.

Message me.
 
Continue Read »

 
 
About This Item:
 
I will supply the vehicle to collect you any ware in Western Cape and deliver you safely.
We need to discuss your requirements beforehand to work out a price as there are different scenarios.

1. Pickup and deliver to venue
2. Pickup, wait at end and return you safely
3. Custom request. Tour, Sight seeing, adventure, Sleep out possible, Bookings all your needs will be catered for.

Message me.
  Collapse Read »

I will answer anything about cape town, $5 = Ask me and I will answer anything about Cape Town 1 Day Delivery

 

 
Ask me anything about Cape Town and I will answer, I am born and raised in Cape Town. 

One of the most beautiful cities in the world. 

Perhaps you are traveling to Cape Town? Perhaps your kid will be studying in Cape Town soon?
Perhaps you are relocating or thinking about it?

Whatever your reason, I will provide an honest answer.
Continue Read »
 

 
Ask me anything about Cape Town and I will answer, I am born and raised in Cape Town. 

One of the most beautiful cities in the world. 

Perhaps you are traveling to Cape Town? Perhaps your kid will be studying in Cape Town soon?
Perhaps you are relocating or thinking about it?

Whatever your reason, I will provide an honest answer. Collapse Read »

I will send you a postcard from cape town, $5 = I will send you a postcard from Cape Town, South Africa 7 Days Delivery

 
 
 

 
Greetings! 

I will send you, or your loved ones a random postcard (with a South African stamp on it) from Cape Town, South Africa!

Designs are picked at random, but feel free to leave a message with the postcard designs preference (i.e.: mountains, animals, beaches, etc)

In your message please include the name and address of the recipient, along with whatever personal message you would like to write on there. :)

Postcards make such a fun gift for family or friends, or just a great addition to your collection! 

*Please allow up to 7 days or more the post card to arrive. I will send you a photo before I ship, but I cannot guarantee delivery upon different mail systems
Continue Read »
 
 
 

 
Greetings! 

I will send you, or your loved ones a random postcard (with a South African stamp on it) from Cape Town, South Africa!

Designs are picked at random, but feel free to leave a message with the postcard designs preference (i.e.: mountains, animals, beaches, etc)

In your message please include the name and address of the recipient, along with whatever personal message you would like to write on there. :)

Postcards make such a fun gift for family or friends, or just a great addition to your collection! 

*Please allow up to 7 days or more the post card to arrive. I will send you a photo before I ship, but I cannot guarantee delivery upon different mail systems Collapse Read »

Africalocals.com Buyer Protection, MONEY BACK GUARANTEE and Terms & Conditions






                                                                            MONEY BACK GUARANTEE
 
We promise your money back if the item you received is not as described, or if your item is not delivered within the Buyer Protection period. You can get a refund 15 days after the claim process finishes. This guarantee is in addition to and does not limit your statutory rights as a consumer, as granted by all mandatory laws and regulations applicable in your country of residence.
 
 
1. Contact Seller
 
Go to your order history and select the item. Discuss the issue with the seller and see possible solutions.
 
2. Apply for Refund
 
If you can't come to an amicable agreement after contacting the seller, simply raise a claim by opening a dispute within 15 days following the delivery of your order or the end of the package receipt confirmation period (as listed in your order details).
 
 
3. Get Money Back in 15 Days

 
Most sellers will return your money in 15 days, however; if it's not resolved, you can contact kiwikiwifly from the order detail page to escalate your dispute.
 
 
Q&A From Sellers and Buyers

What can I sell?

Be creative! You can offer any service you wish as long as it's legal and complies with our terms. There are over 200 categories you can browse to get ideas.
 
 

How much time will I need to invest?

It's very flexible. You need to put in some time and effort in the beginning to learn the shopping mall and then you can decide for yourself what amount of work you want to do.
 

How much money can I make?

It's totally up to you. You can work as much as you want. Many sellers work on kiwikiwifly shopping mall full time and some keep their 9-5 job while using Africalocals shopping mall to make extra money.
 

How do I price my service?

With Africalocals shopping mall Packages, you set your pricing anywhere from $1- $9990 and offer different versions of your service at lots of different prices.
 
How much does it cost

It's free to join Africalocals shopping mall. There is no subscription required or fees to list your products or services. You keep 98% of each transaction.

How do I get paid?

Once you complete a buyer's order, the money is transferred to your account. No need to chase clients for payments and wait 60 or 90 days for a check.
 
 
Buy and Sell on Africalocals marketplace with confidence.

1. Do you know why we chose PayPal as our primary payment method?
2.To ensure you are always protected and secure. You will get exactly what you bought here.
3. All of our seller's products are escrowed or Your Money Back!

Here at Africalocals marketplace we follow and enforce Security Best Practices for all our clients, as well as internally.
We take your security very seriously here on https://www.kiwikiwifly.com We installed multiple layers of security features to keep your information private.

1. Secured SSL encrypted server
2. All purchases will be made over PayPal’s secure server
3. PayPal Security for all Credit Card or Debit Card Payments
4. We don’t store personal financial information on our servers

We strive to provide our customers with the highest level of service possible. From the first visit to order delivery, we want you to be completely satisfied with your experience.

Our Security & Buyer Protection Features:
 
SSL + Cryptocurrency Escrow + PayPal’s secure server + Smart Contract Program + Bitcoin Multisignature Wallet

I. Secured SSL encrypted server
Africalocals uses the best encryption software in the industry – SSL. We use the most advanced 256bit encryption technology offered. All information is encrypted and transmitted to us in a secure way. Cannot be eavesdropped upon as it is transmitted over the internet. compliant with industry standards. You can verify this by looking for a closed lock icon at the beginning of your web browser and looking for “HTTPS” at the beginning of the address of the web page.
 
Africalocals takes every precaution to protect our clients’ personal information. Your information is protected both online and offline. Further to that, we don’t store personal financial information on our servers.

Please feel safe and secure during your shopping experience with us on our secured SSL encrypted server which is the cutting edge in industry standards of online shopping.

2.  All purchases could be chosen over PayPal’s secure server
 
PayPal is one of the most accepted and secured payments available today. As a policy to protect buyer and seller’s benefit, we only accept payment via paypal. Also, you can simply use your Credit Card or Debit Card on the PayPal website. You can shop with confidence knowing you can your money back when your purchase goes wrong.
 
 
When you pay with PayPal on https://www.africalocals.com, PayPal Buyer Protection offers you comprehensive protection if your eligible transaction has a problem. If an item doesn’t arrive or is significantly not as described, PayPal help you get a full refund.
– Full refund if you don’t receive your order.
– Full refund if the product is not as described
https://www.paypal.com/us/weba ... urity

3. Bitcoin Multisignature wallet
 
Imagine a bank vault that requires more than one key to open: That’s a little how multisignature cryptocurrency wallets work (and why multi-signature wallets are typically called vaults).

You can choose how many keys are allowed to open the vault as well as the minimum number of keys needed to unlock it (e.g., you could have a 2-of-3 multisig where two out of three assigned private keys are needed, 2-of-2, 5-of-7, etc.).
 

Africalocals_bitcoin_escrow_wallet_|Copy-of-Multisig-wallet.png

 
 
It works like this: Justin(Buyer), Vittie(Seller) and Africalocals.com(Mediator) set up a multi-signature crypto wallet where each holds one key and two of the three keys must be present to send a transaction. To make a payment, Justin would create a transaction and sign it with his key; he would then send this transaction to Vittie, who would sign it with her key. From here, Vittie can either send it back to Justin to finalize the transaction or send it to Africalocals.com for him to sign, too (though this last step is not necessary, considering only two of the three keys are needed to unlock the wallet). The step by step tutorial is here :
 
https://www.africalocals.com/b ... about
 
 
Continue Read »





                                                                            MONEY BACK GUARANTEE
 
We promise your money back if the item you received is not as described, or if your item is not delivered within the Buyer Protection period. You can get a refund 15 days after the claim process finishes. This guarantee is in addition to and does not limit your statutory rights as a consumer, as granted by all mandatory laws and regulations applicable in your country of residence.
 
 
1. Contact Seller
 
Go to your order history and select the item. Discuss the issue with the seller and see possible solutions.
 
2. Apply for Refund
 
If you can't come to an amicable agreement after contacting the seller, simply raise a claim by opening a dispute within 15 days following the delivery of your order or the end of the package receipt confirmation period (as listed in your order details).
 
 
3. Get Money Back in 15 Days

 
Most sellers will return your money in 15 days, however; if it's not resolved, you can contact kiwikiwifly from the order detail page to escalate your dispute.
 
 
Q&A From Sellers and Buyers

What can I sell?

Be creative! You can offer any service you wish as long as it's legal and complies with our terms. There are over 200 categories you can browse to get ideas.
 
 

How much time will I need to invest?

It's very flexible. You need to put in some time and effort in the beginning to learn the shopping mall and then you can decide for yourself what amount of work you want to do.
 

How much money can I make?

It's totally up to you. You can work as much as you want. Many sellers work on kiwikiwifly shopping mall full time and some keep their 9-5 job while using Africalocals shopping mall to make extra money.
 

How do I price my service?

With Africalocals shopping mall Packages, you set your pricing anywhere from $1- $9990 and offer different versions of your service at lots of different prices.
 
How much does it cost

It's free to join Africalocals shopping mall. There is no subscription required or fees to list your products or services. You keep 98% of each transaction.

How do I get paid?

Once you complete a buyer's order, the money is transferred to your account. No need to chase clients for payments and wait 60 or 90 days for a check.
 
 
Buy and Sell on Africalocals marketplace with confidence.

1. Do you know why we chose PayPal as our primary payment method?
2.To ensure you are always protected and secure. You will get exactly what you bought here.
3. All of our seller's products are escrowed or Your Money Back!

Here at Africalocals marketplace we follow and enforce Security Best Practices for all our clients, as well as internally.
We take your security very seriously here on https://www.kiwikiwifly.com We installed multiple layers of security features to keep your information private.

1. Secured SSL encrypted server
2. All purchases will be made over PayPal’s secure server
3. PayPal Security for all Credit Card or Debit Card Payments
4. We don’t store personal financial information on our servers

We strive to provide our customers with the highest level of service possible. From the first visit to order delivery, we want you to be completely satisfied with your experience.

Our Security & Buyer Protection Features:
 
SSL + Cryptocurrency Escrow + PayPal’s secure server + Smart Contract Program + Bitcoin Multisignature Wallet

I. Secured SSL encrypted server
Africalocals uses the best encryption software in the industry – SSL. We use the most advanced 256bit encryption technology offered. All information is encrypted and transmitted to us in a secure way. Cannot be eavesdropped upon as it is transmitted over the internet. compliant with industry standards. You can verify this by looking for a closed lock icon at the beginning of your web browser and looking for “HTTPS” at the beginning of the address of the web page.
 
Africalocals takes every precaution to protect our clients’ personal information. Your information is protected both online and offline. Further to that, we don’t store personal financial information on our servers.

Please feel safe and secure during your shopping experience with us on our secured SSL encrypted server which is the cutting edge in industry standards of online shopping.

2.  All purchases could be chosen over PayPal’s secure server
 
PayPal is one of the most accepted and secured payments available today. As a policy to protect buyer and seller’s benefit, we only accept payment via paypal. Also, you can simply use your Credit Card or Debit Card on the PayPal website. You can shop with confidence knowing you can your money back when your purchase goes wrong.
 
 
When you pay with PayPal on https://www.africalocals.com, PayPal Buyer Protection offers you comprehensive protection if your eligible transaction has a problem. If an item doesn’t arrive or is significantly not as described, PayPal help you get a full refund.
– Full refund if you don’t receive your order.
– Full refund if the product is not as described
https://www.paypal.com/us/weba ... urity

3. Bitcoin Multisignature wallet
 
Imagine a bank vault that requires more than one key to open: That’s a little how multisignature cryptocurrency wallets work (and why multi-signature wallets are typically called vaults).

You can choose how many keys are allowed to open the vault as well as the minimum number of keys needed to unlock it (e.g., you could have a 2-of-3 multisig where two out of three assigned private keys are needed, 2-of-2, 5-of-7, etc.).
 

Africalocals_bitcoin_escrow_wallet_|Copy-of-Multisig-wallet.png

 
 
It works like this: Justin(Buyer), Vittie(Seller) and Africalocals.com(Mediator) set up a multi-signature crypto wallet where each holds one key and two of the three keys must be present to send a transaction. To make a payment, Justin would create a transaction and sign it with his key; he would then send this transaction to Vittie, who would sign it with her key. From here, Vittie can either send it back to Justin to finalize the transaction or send it to Africalocals.com for him to sign, too (though this last step is not necessary, considering only two of the three keys are needed to unlock the wallet). The step by step tutorial is here :
 
https://www.africalocals.com/b ... about
 
  Collapse Read »

How to clear the DNS Cache on your macOS?

DNS
Overview 
 
This article provides instructions on how to clear the DNS Cache on a computers and web browsers. This procedure is necessary in order for previously cached resolutions to be cleared out and subsequent lookup to be performed based on newly configured DNS settings.

 

OS X 10.4 TIGER

 

Click the Terminal icon in the dock or in Finder under Application/Utilities/Terminal

     Run the following command in the command line and hit enter
 
lookupd -flushcache

 
 

OS X 10.5 and 10.6 LEOPARD

 

Click the Terminal icon in the dock or in Finder under Application/Utilities/Terminal

     Run the following command in the command line and hit enter

dscacheutil -flushcache

  

OS X 10.7 and 10.8 Lion

 

Click the Terminal icon in the dock or in Finder under Application/Utilities/Terminal


sudo killall -HUP mDNSResponder

 


 

OS X 10.9 and 10.10.4 Yosemite, 10.11 El Capitan and 10.12 Sierra


 

Click the Terminal icon in the dock or in Finder under Application/Utilities/Terminal




sudo dscacheutil -flushcache

sudo killall -HUP mDNSResponder


 
Continue Read »
Overview 
 
This article provides instructions on how to clear the DNS Cache on a computers and web browsers. This procedure is necessary in order for previously cached resolutions to be cleared out and subsequent lookup to be performed based on newly configured DNS settings.

 

OS X 10.4 TIGER

 

Click the Terminal icon in the dock or in Finder under Application/Utilities/Terminal

     Run the following command in the command line and hit enter
 
lookupd -flushcache

 
 

OS X 10.5 and 10.6 LEOPARD

 

Click the Terminal icon in the dock or in Finder under Application/Utilities/Terminal

     Run the following command in the command line and hit enter

dscacheutil -flushcache

  

OS X 10.7 and 10.8 Lion

 

Click the Terminal icon in the dock or in Finder under Application/Utilities/Terminal


sudo killall -HUP mDNSResponder

 


 

OS X 10.9 and 10.10.4 Yosemite, 10.11 El Capitan and 10.12 Sierra


 

Click the Terminal icon in the dock or in Finder under Application/Utilities/Terminal




sudo dscacheutil -flushcache

sudo killall -HUP mDNSResponder


  Collapse Read »

How to modify your DNS on mac OSX Mojave and El Capitan 2020

From this tutorial, you will learn how to modify your dns on your macOS. 
 

Tools:
Mac laptop
 
 1. Go to your mac os System Preferences option, click the apple icon on the top left screen .
 

 
2.  Click on Network
 

 
3. Select the first connection in your list and click Advanced
 

 
 
 
 
 
4. Select the DNS tab and add 208.67.222.222 and 208.67.220.220 to the list of DNS servers. Click OK
 

 
5. cache and web browser caches to ensure that your new DNS configuration settings take immediate effect.



At the point, we highly suggest that you flush your DNS resolver cache and web browser caches to ensure that your new DNS configuration settings take immediate effect.

 
Video Instruction:
 
 






 
Continue Read »
From this tutorial, you will learn how to modify your dns on your macOS. 
 

Tools:
Mac laptop
 
 1. Go to your mac os System Preferences option, click the apple icon on the top left screen .
 

 
2.  Click on Network
 

 
3. Select the first connection in your list and click Advanced
 

 
 
 
 
 
4. Select the DNS tab and add 208.67.222.222 and 208.67.220.220 to the list of DNS servers. Click OK
 

 
5. cache and web browser caches to ensure that your new DNS configuration settings take immediate effect.



At the point, we highly suggest that you flush your DNS resolver cache and web browser caches to ensure that your new DNS configuration settings take immediate effect.

 
Video Instruction:
 
 






  Collapse Read »

Dreamlabs | Mobile App Development Company Abuja – Android & IOS

DreamLabs harnesses the power of technology to help organizations greatly improve employee productivity, make their processes more efficient, systems more powerful and customer experiences exceptional.

With deep technology and industry expertise, innovative financing mechanisms, we offer a full consultative based approach to identify the true needs of our clients and help build highly innovative and efficient solutions across the entire enterprise value chain. Our team leverages on proprietary proven agile methodologies in the management of our client projects and are able to deliver large project in functional incremental units at speed.

DreamLabs specializes in scalable, hybrid mobile app development for android, windows and iphones.
https://www.dreamlabs.com.ng/i ... ment/

Website : https://www.dreamlabs.com.ng/
Email : [email protected]
Telephone : +2349059555228
Continue Read »
DreamLabs harnesses the power of technology to help organizations greatly improve employee productivity, make their processes more efficient, systems more powerful and customer experiences exceptional.

With deep technology and industry expertise, innovative financing mechanisms, we offer a full consultative based approach to identify the true needs of our clients and help build highly innovative and efficient solutions across the entire enterprise value chain. Our team leverages on proprietary proven agile methodologies in the management of our client projects and are able to deliver large project in functional incremental units at speed.

DreamLabs specializes in scalable, hybrid mobile app development for android, windows and iphones.
https://www.dreamlabs.com.ng/i ... ment/

Website : https://www.dreamlabs.com.ng/
Email : [email protected]
Telephone : +2349059555228 Collapse Read »

DreamLabs | A Mobile & Web App Development Company

Dreamlabs specializes in scalable, hybrid/cross-platform mobile app development for android, windows, and iPhones, across Abuja and Nigeria.
 
DreamLabs harnesses the power of technology to help organizations greatly improve employee productivity, make their processes more efficient, systems more powerful and customer experiences exceptional.

With deep technology and industry expertise, innovative financing mechanisms, we offer a full consultative based approach to identify the true needs of our clients and help build highly innovative and efficient solutions across the entire enterprise value chain. Our team leverages on proprietary proven agile methodologies in the management of our client projects and are able to deliver a large project in functional incremental units at speed.

As an IT company, Software company, our major services and expertise are based web application design/development, mobile app development company, revenue automation.

Website: https://www.dreamlabs.com.ng/  
Email: [email protected]
Telephone : +2349059555228
More information on our mobile app development capacity: Click here https://www.dreamlabs.com.ng/i ... ment/
 

 
Continue Read »
Dreamlabs specializes in scalable, hybrid/cross-platform mobile app development for android, windows, and iPhones, across Abuja and Nigeria.
 
DreamLabs harnesses the power of technology to help organizations greatly improve employee productivity, make their processes more efficient, systems more powerful and customer experiences exceptional.

With deep technology and industry expertise, innovative financing mechanisms, we offer a full consultative based approach to identify the true needs of our clients and help build highly innovative and efficient solutions across the entire enterprise value chain. Our team leverages on proprietary proven agile methodologies in the management of our client projects and are able to deliver a large project in functional incremental units at speed.

As an IT company, Software company, our major services and expertise are based web application design/development, mobile app development company, revenue automation.

Website: https://www.dreamlabs.com.ng/  
Email: [email protected]
Telephone : +2349059555228
More information on our mobile app development capacity: Click here https://www.dreamlabs.com.ng/i ... ment/
 

  Collapse Read »

Do you have issues on business transaction in Nigeria?SafeTrader output AI-powered escrow service to secure your transaction for your business.

Q1: Hi, Daniel, What's your education background, what were you working on before this startup SafeTrader. What's your work experience, Can you introduce your business to our users?

I’m a student of Communication Technology from National open university. Before starting safeTrader

I was working at Kiakia.co. As a programmer. That was where I met my co-founder Adeniyi Mikail, and we came up with a solution to help stop the prevailing existence of online fraud in Nigeria.



Q2: How did you get into the programming world? and became a developer? How did that happen?


I’ve always been passionate about programming, I started coding as a hobby after my secondary school. While in the university, I decided to take it more seriously, from then on I’ve been building websites and web applications. 



Q3: What experience or idea inspires you to get started with SafeTrader and what does this mean to users in Nigeria? (If you can, please attach related photos about that experience )

SafeTrader was started out of genuine concern. We realized that the prevailing existence of fraud needed to be checked as it accounts for the loss of revenue to one or all parties involved in a business or trade agreement. We, therefore, designed a system that guarantees trust and provides a cushion of safety to enable smooth and hitch-free transactions both online and offline.



Q4: How SafeTrader works? What are the services you can offer on your website? How did you find clients who wanna buy your services? Why did users willing to use your products and services?

Safetrader is an AI-powered escrow service startup, established with the aim of providing safety and safeguarding the trust of parties to a business transaction in Nigeria, Africa and the world at large.

We use a chatbot with the aim of providing a system where business can be transacted with peace of mind, trust and without fear. We do this by acting as a trusted third party who ensures that all parties are held accountable to the terms of the agreement they entered in the course of transacting any business. 

Users are willing to use safeTrader because of the ease and simplicity of our services, It is accessible from your mobile phone or personal computer within minutes, and your transaction is secure.




Q5: What are your thoughts on the current state of IT industry and online shopping in Nigeria? How can your services help users?

The IT industry and online shopping in Nigeria is still developing, in the online shopping industry there have a been a lot of improvements, before it used to be order online and pay online, now there are other options like pay on delivery, even though most online stores still prefer pay before delivery because of the challenge of some sellers not trusting the buyers. In most cases, the buyers also don't trust the sellers or they’re are skeptical about paying for goods they’ve not received. This is where SafeTrader comes in, our services help to allow that environment of trust, so business owners can do business without fear and the buyers also can shop with anybody knowing that they run no risk to their funds.



Q6: How did you find your co-founders and employees? What's the story of how you set up your team? (please attach some team photos and co-founders photos)

My co-founder and I were both colleagues at a former place of employment. I was in the tech department and he was in the business support department, from interactions we realized that we had aligned interest. That was what started the journey for us. 

The members of the team were past colleagues from our separate places of employment before we met each other. The team is made of people that we need to achieve the goals that we set. We also have someone on the team that was based on the recommendation from a trusted senior colleague in the industry.

That is how the team is set up.



Q7: When you guys began to build this startup, what were the difficulties your team faced and how did you guys fix them?

An essential difficulty we faced was funding, but we dipped into our personal savings along with support from an angel investor, and we were able to overcome this initial hurdle. 



Q8: How did you get initial money to start the business? Did you raise some investment from angel investors like other companies?


We are currently running on funds from an angel investor and our personal seed capital.

Q9: How did you attract new users to your website and scale your business? What are the useful and practical operation methods you can share?

Currently, we get news users from social media and referrals. Social media marketing is one of the fastest ways to gain exposure to any type of business. 


Q10: How can you secure your services are reliable and trustable? How can you ensure security between buyers and sellers? How can you fix transaction disputes between buyers and sellers? Would bad services exist? How to avoid these happen? Can you recommend one successful client example from your website? What did he get after he used your services? What is the link to it? (If you can, please attach related photos about these )

We are very reliable, An example is a client in Ibadan who needed the services of an app developer in Abuja. Because of SafeTrader he felt comfortable to do a transaction with someone he doesn’t have physical contact with. The client was very understanding saw the progress the developer has made and opted to give him an extension to enable him to complete the project. At the end of the day, everybody was happy.

Would there be bad services? 

Definitely, Some people are out to defraud people, some just disappoint. An example is an artisan that takes too much work and is unable to meet with the delivery date and ends up disappointing his clients.

Q11. How do you fix transaction dispute? 

The full details of a transaction (the kind of services they want, when the job will be delivered) are filled before the transaction starts. When a due date is approaching we reach out to both party to be sure the service provider will be able to deliver on that day, and that the client is still on course and understands what is going on. If the service provider is unable to deliver we reach out to both parties to find an alternative solution and to know if it’s a minor delay or we need to cancel the transaction and make a refund. 

We try to ensure there’s no dispute in the first place that’s why we are constantly communicating with both parties.




Q12: How did you grow your revenue? What's the story behind how you got your first revenue from clients?


The first revenue stream and first few clients were people we know (Friends/Family). They, in turn, helped to inform the other members of the public, and word of mouth spread the message. 


Q14: What is the advice do you have for newcomers who want to get into the Internet and programming area?

Everyone is zero at the time of starting, make lots of mistakes, always find time to learn and most importantly Invest in yourself!


Q15: What're your goals for your business?  Why do those goals are important for you?

we are looking to become the household name and the go-to company when it comes to safety and security in commerce. We hope to be the game-changer, the narrative changer with respect to transacting with Nigerians internationally. We hope to make Nigerian businesses and business owners attractive and trustworthy to completely eradicate the fear factor associated with dealing with our countrymen internationally. 


Q16: How do you keep learning? Where do you go to learn more?


I create time to always learn, I learn from industry experts, I learn from my mentors, Online course.

Some of the sites I go to learn:

Scotch io - https://scotch.io/

Udacity - https://www.udacity.com/


LinkedIn Learning - https://www.linkedin.com/learning/


Q17: What do you do on a daily or a weekly basis that you think is important in terms of forming your skills and opinions on this area?

What is the one day like you usually do? (e.g. 9:00- 12:00 programming, 13:30- 15:30 meet clients)

I set goals for myself on a weekly basis, things I need to read, things I need to learn, areas I need to improve. And most importantly brainstorm on areas we need to make safeTrader better.


Q18: What's your biggest surprise over the last three, four years in the internet industry where you have been working? What happened that you didn't expect?

That has to be “Amazon surpassing Microsoft as the largest company by market value”

Q19: What's your plan for your business in the next months? What's your business roadmap for next year?


For many parts of our early development, it has been about fine-tuning the service and we are now convinced that the priority for 2019 is to expand further and grow the number of users. We intend to achieve this through increased expenditure in the area of advertisement and sensitization, an area we have neglected before.
We are also looking at collaborating with more businesses that would require our services regularly in line with the kind of operations they carry out.



Q20: Where can we know more official info about you and your companies?

Our Official website

https://www.safetrader.ng

facebook

https://www.facebook.com/safetrader.ng/

Twitter

https://twitter.com/_Safetrader

ISHOLA DANIEL

Co-Founder/CTO

SafeTrader 

P:  +2348188001165

E: [email protected]

W: www.safetrader.ng
Continue Read »
Q1: Hi, Daniel, What's your education background, what were you working on before this startup SafeTrader. What's your work experience, Can you introduce your business to our users?

I’m a student of Communication Technology from National open university. Before starting safeTrader

I was working at Kiakia.co. As a programmer. That was where I met my co-founder Adeniyi Mikail, and we came up with a solution to help stop the prevailing existence of online fraud in Nigeria.



Q2: How did you get into the programming world? and became a developer? How did that happen?


I’ve always been passionate about programming, I started coding as a hobby after my secondary school. While in the university, I decided to take it more seriously, from then on I’ve been building websites and web applications. 



Q3: What experience or idea inspires you to get started with SafeTrader and what does this mean to users in Nigeria? (If you can, please attach related photos about that experience )

SafeTrader was started out of genuine concern. We realized that the prevailing existence of fraud needed to be checked as it accounts for the loss of revenue to one or all parties involved in a business or trade agreement. We, therefore, designed a system that guarantees trust and provides a cushion of safety to enable smooth and hitch-free transactions both online and offline.



Q4: How SafeTrader works? What are the services you can offer on your website? How did you find clients who wanna buy your services? Why did users willing to use your products and services?

Safetrader is an AI-powered escrow service startup, established with the aim of providing safety and safeguarding the trust of parties to a business transaction in Nigeria, Africa and the world at large.

We use a chatbot with the aim of providing a system where business can be transacted with peace of mind, trust and without fear. We do this by acting as a trusted third party who ensures that all parties are held accountable to the terms of the agreement they entered in the course of transacting any business. 

Users are willing to use safeTrader because of the ease and simplicity of our services, It is accessible from your mobile phone or personal computer within minutes, and your transaction is secure.




Q5: What are your thoughts on the current state of IT industry and online shopping in Nigeria? How can your services help users?

The IT industry and online shopping in Nigeria is still developing, in the online shopping industry there have a been a lot of improvements, before it used to be order online and pay online, now there are other options like pay on delivery, even though most online stores still prefer pay before delivery because of the challenge of some sellers not trusting the buyers. In most cases, the buyers also don't trust the sellers or they’re are skeptical about paying for goods they’ve not received. This is where SafeTrader comes in, our services help to allow that environment of trust, so business owners can do business without fear and the buyers also can shop with anybody knowing that they run no risk to their funds.



Q6: How did you find your co-founders and employees? What's the story of how you set up your team? (please attach some team photos and co-founders photos)

My co-founder and I were both colleagues at a former place of employment. I was in the tech department and he was in the business support department, from interactions we realized that we had aligned interest. That was what started the journey for us. 

The members of the team were past colleagues from our separate places of employment before we met each other. The team is made of people that we need to achieve the goals that we set. We also have someone on the team that was based on the recommendation from a trusted senior colleague in the industry.

That is how the team is set up.



Q7: When you guys began to build this startup, what were the difficulties your team faced and how did you guys fix them?

An essential difficulty we faced was funding, but we dipped into our personal savings along with support from an angel investor, and we were able to overcome this initial hurdle. 



Q8: How did you get initial money to start the business? Did you raise some investment from angel investors like other companies?


We are currently running on funds from an angel investor and our personal seed capital.

Q9: How did you attract new users to your website and scale your business? What are the useful and practical operation methods you can share?

Currently, we get news users from social media and referrals. Social media marketing is one of the fastest ways to gain exposure to any type of business. 


Q10: How can you secure your services are reliable and trustable? How can you ensure security between buyers and sellers? How can you fix transaction disputes between buyers and sellers? Would bad services exist? How to avoid these happen? Can you recommend one successful client example from your website? What did he get after he used your services? What is the link to it? (If you can, please attach related photos about these )

We are very reliable, An example is a client in Ibadan who needed the services of an app developer in Abuja. Because of SafeTrader he felt comfortable to do a transaction with someone he doesn’t have physical contact with. The client was very understanding saw the progress the developer has made and opted to give him an extension to enable him to complete the project. At the end of the day, everybody was happy.

Would there be bad services? 

Definitely, Some people are out to defraud people, some just disappoint. An example is an artisan that takes too much work and is unable to meet with the delivery date and ends up disappointing his clients.

Q11. How do you fix transaction dispute? 

The full details of a transaction (the kind of services they want, when the job will be delivered) are filled before the transaction starts. When a due date is approaching we reach out to both party to be sure the service provider will be able to deliver on that day, and that the client is still on course and understands what is going on. If the service provider is unable to deliver we reach out to both parties to find an alternative solution and to know if it’s a minor delay or we need to cancel the transaction and make a refund. 

We try to ensure there’s no dispute in the first place that’s why we are constantly communicating with both parties.




Q12: How did you grow your revenue? What's the story behind how you got your first revenue from clients?


The first revenue stream and first few clients were people we know (Friends/Family). They, in turn, helped to inform the other members of the public, and word of mouth spread the message. 


Q14: What is the advice do you have for newcomers who want to get into the Internet and programming area?

Everyone is zero at the time of starting, make lots of mistakes, always find time to learn and most importantly Invest in yourself!


Q15: What're your goals for your business?  Why do those goals are important for you?

we are looking to become the household name and the go-to company when it comes to safety and security in commerce. We hope to be the game-changer, the narrative changer with respect to transacting with Nigerians internationally. We hope to make Nigerian businesses and business owners attractive and trustworthy to completely eradicate the fear factor associated with dealing with our countrymen internationally. 


Q16: How do you keep learning? Where do you go to learn more?


I create time to always learn, I learn from industry experts, I learn from my mentors, Online course.

Some of the sites I go to learn:

Scotch io - https://scotch.io/

Udacity - https://www.udacity.com/


LinkedIn Learning - https://www.linkedin.com/learning/


Q17: What do you do on a daily or a weekly basis that you think is important in terms of forming your skills and opinions on this area?

What is the one day like you usually do? (e.g. 9:00- 12:00 programming, 13:30- 15:30 meet clients)

I set goals for myself on a weekly basis, things I need to read, things I need to learn, areas I need to improve. And most importantly brainstorm on areas we need to make safeTrader better.


Q18: What's your biggest surprise over the last three, four years in the internet industry where you have been working? What happened that you didn't expect?

That has to be “Amazon surpassing Microsoft as the largest company by market value”

Q19: What's your plan for your business in the next months? What's your business roadmap for next year?


For many parts of our early development, it has been about fine-tuning the service and we are now convinced that the priority for 2019 is to expand further and grow the number of users. We intend to achieve this through increased expenditure in the area of advertisement and sensitization, an area we have neglected before.
We are also looking at collaborating with more businesses that would require our services regularly in line with the kind of operations they carry out.



Q20: Where can we know more official info about you and your companies?

Our Official website

https://www.safetrader.ng

facebook

https://www.facebook.com/safetrader.ng/

Twitter

https://twitter.com/_Safetrader

ISHOLA DANIEL

Co-Founder/CTO

SafeTrader 

P:  +2348188001165

E: [email protected]

W: www.safetrader.ng Collapse Read »

How to let you own local computer out of government spy and censorship from isp companies


1. go to https://www.dnsleaktest.com/ to check out, you will find two buttons in the middle of the screen. one is the standard model, the other is the extended test. Ok, let us click the standard model first. At the same time, you don’t need to use the VPN network. if you see your isp name on it(e.g. China Telecom,China Unicom,verizon, sprint, AT&T, T-mobile, etc),  that means you are recorded by these companies, and the local government would ask them for users’ data illegally. Now we need to go to modify our DNS record on our own computer 
 




After you modified, you can test your network on https://www.dnsleaktest.com/ again, and you would find, your records like these.


 
 
[/url]



cool, now, you can enjoy your fun on the internet, if you always use tor browser and vpn, that would be better get out of the spies of governments and devil eyes.
Continue Read »

1. go to https://www.dnsleaktest.com/ to check out, you will find two buttons in the middle of the screen. one is the standard model, the other is the extended test. Ok, let us click the standard model first. At the same time, you don’t need to use the VPN network. if you see your isp name on it(e.g. China Telecom,China Unicom,verizon, sprint, AT&T, T-mobile, etc),  that means you are recorded by these companies, and the local government would ask them for users’ data illegally. Now we need to go to modify our DNS record on our own computer 
 




After you modified, you can test your network on https://www.dnsleaktest.com/ again, and you would find, your records like these.


 
 
[/url]



cool, now, you can enjoy your fun on the internet, if you always use tor browser and vpn, that would be better get out of the spies of governments and devil eyes. Collapse Read »

Clarity- smart contract language reference

Clarity language reference




This file contains the reference for the Clarity language.

Block Properties
Supported types

Int type
Bool type
Buffer type
List type
Principal type
Tuple type
Optional type
Response type

Native variables

block-height
contract-name
tx-sender

Clarity function reference

* (multiply)
+ (add)
- (subtract)
/ (divide)
< (less than)
<= (less than or equal)
> (greater than)
>= (greater than or equal)
and
as-contract
begin
contract-call!
default-to
define-data-var
define-map
define-public
define-read-only
define
delete-entry!
eq?
err
expects!
expects-err!
fetch-contract-entry
fetch-entry
fetch-var
filter
fold
get-block-info
get
hash160
if
insert-entry!
is-none?
is-ok?
keccak256
let
list
map
mod
not
ok
or
pow
print
set-entry!
set-var!
sha256
tuple
xor




Block Properties

The get-block-info function fetches property details for a block at a specified block height. For example:

(get-block-info time 10) ;; Returns 1557860301

Because the Clarity language is in pre-release, the block properties that are fetched are simulated properties from a SQLite database. The available property names are:

Property

Definition

header-hash

A 32-byte buffer containing the block hash.

burnchain-header-hash

A 32-byte buffer that contains the hash from the proof of burn.

vrf-seed

A 32-byte buffer containing the Verifiable Random Function (VRF) seed value used for the block.

time

An integer value containing that roughly corresponds to when the block was mined. This is a Unix epoch timestamp in seconds.

Warning: The time does not increase monotonically with each block. Block times are accurate only to within two hours. See BIP113 for more information.




Supported types

This section lists the types available to smart contracts. The only atomic types supported by the Clarity are booleans, integers, fixed length buffers, and principals.




Int type

The integer type in the Clarity language is a 16-byte signed integer, which allows it to specify the maximum amount of microstacks spendable in a single Stacks transfer. The special BlockHeightInt you can obtain with the get-block-info function.




Bool type

Supports values of 'true or 'false.




Buffer type

Buffer types represent fixed-length byte buffers. Currently, the only way to construct a Buffer is using string literals, for example "alice.id" or hash160("bob.id")

All of the hash functions return buffers:

hash160 sha256 keccak256

The block properties header-hash, burnchain-header-hash, and vrf-seed are all buffers.




List type

Clarity supports lists of the atomic types. However, the only variable length lists in the language appear as function inputs; there is no support for list operations like append or join.




Principal type

Clarity provides this primitive for checking whether or not the smart contract transaction was signed by a particular principal. Principals represent a spending entity and are roughly equivalent to a Stacks address. The principal’s signature is not checked by the smart contract, but by the virtual machine. A smart contract function can use the globally defined tx-sender variable to obtain the current principal.

Smart contracts may also be principals (represented by the smart contract’s identifier). However, there is no private key associated with the smart contract, and it cannot broadcast a signed transaction on the blockchain. A smart contract uses the special variable contract-name to refer to its own principal.




Tuple type

To support the use of named fields in keys and values, Clarity allows the construction of named tuples using a function (tuple ...), for example

(define imaginary-number-a (tuple (real 1) (i 2)))

(define imaginary-number-b (tuple (real 2) (i 3)))

This allows for creating named tuples on the fly, which is useful for data maps where the keys and values are themselves named tuples. Values in a given mapping are set or fetched using:

Function

Description

(fetch-entry map-name key-tuple)

Fetches the value associated with a given key in the map, or returns none if there is no such value.

(set-entry! map-name key-tuple value-tuple)

Sets the value of key-tuple in the data map

(insert-entry! map-name key-tuple value-tuple)

Sets the value of key-tuple in the data map if and only if an entry does not already exist.

(delete-entry! map-name key-tuple)

Deletes key-tuple from the data map.

To access a named value of a given tuple, the (get name tuple) function returns that item from the tuple.




Optional type

Represents an optional value. This is used in place of the typical usage of “null” values in other languages, and represents a type that can either be some value or none. Optional types are used as the return types of data-map functions.




Response type

Response types represent the result of a public function. Use this type to indicate and return data associated with the execution of the function. Also, the response should indicate whether the function error’ed (and therefore did not materialize any data in the database) or ran ok (in which case data materialized in the database).

Response types contain two subtypes – a response type in the event of ok (that is, a public function returns an integer code on success) and an err type (that is, a function returns a buffer on error).




Native variables

The Clarity language includes native variables you can use in your contract.




block-height

The height of a block in the Stacks blockchain. Block height is the number of blocks in the chain between any given block and the very first block in the blockchain. You can obtain a block-height via the get-block-info function.




contract-name

Represents the current contract.




tx-sender

Represents the current principal. This variable does not change during inter-contract calls. This means that if a transaction invokes a function in a given smart contract, that function is able to make calls into other smart contracts on your behalf. This enables a wide variety of applications, but it comes with some dangers for users of smart contracts. Static analysis of Clarity contracts guarantees the language allows clients to deduce which functions a given smart contract will ever call. Good clients should always warn users about any potential side effects of a given transaction.




Clarity function reference




* (multiply)

Syntax (* i1 i2...)

Input type:

int, ...

Output type:

int

Multiplies a variable number of integer inputs and returns the result. In the event of an overflow, throws a runtime error.




Example

(* 2 3) ;; Returns 6

(* 5 2) ;; Returns 10

(* 2 2 2) ;; Returns 8







+ (add)

Syntax (+ i1 i2...)

Input type:

int, ...

Output type:

int

Adds a variable number of integer inputs and returns the result. In the event of an overflow, throws a runtime error.




Example

(+ 1 2 3) ;; Returns 6







- (subtract)

Syntax (- i1 i2...)

Input type:

int, ...

Output type:

int

Subtracts a variable number of integer inputs and returns the result. In the event of an underflow, throws a runtime error.




Example

(- 2 1 1) ;; Returns 0

(- 0 3) ;; Returns -3







/ (divide)

Syntax (/ i1 i2...)

Input type:

int, ...

Output type:

int

Integer divides a variable number of integer inputs and returns the result. In the event of division by zero, throws a runtime error.




Example

(/ 2 3) ;; Returns 0

(/ 5 2) ;; Returns 2

(/ 4 2 2) ;; Returns 1







< (less than)

Syntax (< i1 i2)

Input type:

int, int

Output type:

bool

Compares two integers, returning true if i1 is less than i2 and false otherwise.




Example

(< 1 2) ;; Returns 'true

(< 5 2) ;; Returns 'false







<= (less than or equal)

Syntax (> i1 i2)

Input type:

int, int

Output type:

bool

Compares two integers, returning true if i1 is less than or equal to i2 and false otherwise.




Example

(<= 1 1) ;; Returns 'true

(<= 5 2) ;; Returns 'false







> (greater than)

Syntax (> i1 i2)

Input type:

int, int

Output type:

bool

Compares two integers, returning true if i1 is greater than i2 and false otherwise.




Example

(> 1 2) ;; Returns 'false

(> 5 2) ;; Returns 'true







>= (greater than or equal)

Syntax (>= i1 i2)

Input type:

int, int

Output type:

bool

Compares two integers, returning true if i1 is greater than or equal to i2 and false otherwise.




Example

(>= 1 1) ;; Returns 'true

(>= 5 2) ;; Returns 'true







and

Syntax (and b1 b2 ...)

Input type:

bool, ...

Output type:

bool

Returns true if all boolean inputs are true. Importantly, the supplied arguments are evaluated in-order and lazily. Lazy evaluation means that if one of the arguments returns false, the function short-circuits, and no subsequent arguments are evaluated.




Example

(and 'true 'false) ;; Returns 'false

(and (eq? (+ 1 2) 1) (eq? 4 4)) ;; Returns 'false

(and (eq? (+ 1 2) 3) (eq? 4 4)) ;; Returns 'true







as-contract

Syntax (as-contract expr)

Input type:

A

Output type:

A

The as-contract function switches the current context’s tx-sender value to the contract’s principal and executes expr with that context. It returns the resulting value of expr.




Example

(as-contract (print tx-sender)) ;; Returns 'CTcontract.name







begin

Syntax (begin expr1 expr2 expr3 ... expr-last)

Input type:

AnyType, ... A

Output type:

A

The begin function evaluates each of its input expressions, returning the return value of the last such expression.




Example

(begin (+ 1 2) 4 5) ;; Returns 5







contract-call!

Syntax (contract-call! contract-name function-name arg0 arg1 ...)

Input type:

ContractName, PublicFunctionName, Arg0, ...

Output type:

Response(A,B)

The contract-call! function executes the given public function of the given contract. You may not this function to call a public function defined in the current contract. If the public function returns err, any database changes resulting from calling contract-call! are aborted. If the function returns ok, database changes occurred.




Example

(contract-call! tokens transfer 'SZ2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKQ9H6DPR 19) ;; Returns (ok 1)







default-to

Syntax (default-to default-value option-value)

Input type:

A, Optional(A)

Output type:

A

The default-to function attempts to ‘unpack’ the second argument: if the argument is a (some ...) option, it returns the inner value of the option. If the second argument is a (none) value, default-to it returns the value of default-value.




Example

(default-to 0 (get id (fetch-entry names-map (tuple (name "blockstack"))))) ;; Returns 1337

(default-to 0 (get id (fetch-entry names-map (tuple (name "non-existant"))))) ;; Returns 0







define-data-var

Syntax (define-data-var var-name type value)

Input type:

VarName, TypeDefinition, Value

Output type:

Not Applicable

define-data-var is used to define a new persisted variable for use in a smart contract. Such variable are only modifiable by the current smart contract.

Persisted variable are defined with a type and a value.

Like other kinds of definition statements, define-data-var may only be used at the top level of a smart contract definition (i.e., you cannot put a define statement in the middle of a function body).




Example

(define-data-var size int 0)

(define (set-size (value int))

  (set-var! size value))

(set-size 1)

(set-size 2)







define-map

Syntax (define-map map-name ((key-name-0 key-type-0) ...) ((val-name-0 val-type-0) ...))

Input type:

MapName, KeyTupleDefinition, MapTupleDefinition

Output type:

Not Applicable

define-map is used to define a new datamap for use in a smart contract. Such maps are only modifiable by the current smart contract.

Maps are defined with a key tuple type and value tuple type. These are defined using a list of name and type pairs, e.g., a key type might be ((id int)), which is a tuple with a single “id” field of type int.

Like other kinds of definition statements, define-map may only be used at the top level of a smart contract definition (i.e., you cannot put a define statement in the middle of a function body).




Example

(define-map squares ((x int)) ((square int)))

(define (add-entry (x int))

  (insert-entry! squares ((x 2)) ((square (* x x)))))

(add-entry 1)

(add-entry 2)

(add-entry 3)

(add-entry 4)

(add-entry 5)







define-public

Syntax (define-public (function-name (arg-name-0 arg-type-0) (arg-name-1 arg-type-1) ...) function-body)

Input type:

MethodSignature, MethodBody

Output type:

Not Applicable

define-public is used to define a public function and transaction for a smart contract. Public functions are callable from other smart contracts and may be invoked directly by users by submitting a transaction to the Stacks blockchain.

Like other kinds of definition statements, define-public may only be used at the top level of a smart contract definition (i.e., you cannot put a define statement in the middle of a function body).

Public functions must return a ResponseType (using either ok or err). Any datamap modifications performed by a public function is aborted if the function returns an err type. Public functions may be invoked by other contracts via contract-call!.




Example

(define-public (hello-world (input int))

  (begin (print (+ 2 input))

         (ok input)))







define-read-only

Syntax (define-read-only (function-name (arg-name-0 arg-type-0) (arg-name-1 arg-type-1) ...) function-body)

Input type:

MethodSignature, MethodBody

Output type:

Not Applicable

define-read-only is used to define a public read-only function for a smart contract. Such functions are callable from other smart contracts.

Like other kinds of definition statements, define-read-only may only be used at the top level of a smart contract definition (i.e., you cannot put a define statement in the middle of a function body).

Read-only functions may return any type. However, read-only functions may not perform any datamap modifications, or call any functions which perform such modifications. This is enforced both during type checks and during the execution of the function. Public read-only functions may be invoked by other contracts via contract-call!.




Example

(define-read-only (just-return-one-hundred)

  (* 10 10))







define

Syntax (define (function-name (arg-name-0 arg-type-0) (arg-name-1 arg-type-1) ...) function-body)

Input type:

MethodSignature, MethodBody

Output type:

Not Applicable

define is used to define private functions for a smart contract. Private functions may not be called from other smart contracts, nor may they be invoked directly by users. Instead, these functions may only be invoked by other functions defined in the same smart contract.

Like other kinds of definition statements, define may only be used at the top level of a smart contract definition (i.e., you cannot put a define statement in the middle of a function body).

Private functions may return any type.




Example

(define (max-of (i1 int) (i2 int))

  (if (> i1 i2)

      i1

      i2))

(max-of 4 6) ;; returns 6







delete-entry!

Syntax (delete-entry! map-name key-tuple)

Input type:

MapName, Tuple

Output type:

bool

The delete-entry! function removes the value associated with the input key for the given map. If an item exists and is removed, the function returns true. If a value did not exist for this key in the data map, the function returns false.




Example

(delete-entry! names-map (tuple (name "blockstack"))) ;; Returns 'true

(delete-entry! names-map (tuple (name "blockstack"))) ;; Returns 'false

(delete-entry! names-map ((name "blockstack"))) ;; Same command, using a shorthand for constructing the tuple







eq?

Syntax (eq? v1 v2...)

Input type:

A, A, ...

Output type:

bool

Compares the inputted values, returning true if they are all equal. Note that unlike the (and ...) function, (eq? ...) will not short-circuit.




Example

(eq? 1 1) ;; Returns 'true

(eq? 1 'false) ;; Returns 'false

(eq? "abc" 234 234) ;; Returns 'false







err

Syntax (err value)

Input type:

A

Output type:

Response(A,B)

The err function constructs a response type from the input value. Use err for creating return values in public functions. An err value indicates that any database changes during the processing of the function should be rolled back.




Example

(err 'true) ;; Returns (err 'true)







expects!

Syntax (expects! option-input thrown-value)

Input type:

Optional(A) | Response(A,B), C

Output type:

A

The expects! function attempts to ‘unpack’ the first argument: if the argument is an option type, and the argument is a (some ...) option, expects! returns the inner value of the option. If the argument is a response type, and the argument is an (ok ...) response, expects! returns the inner value of the ok. If the supplied argument is either an (err ...) or a (none) value, expects! returns thrown-value from the current function and exits the current control-flow.




Example

(expects! (fetch-entry names-map (tuple (name "blockstack"))) (err 1)) ;; Returns (tuple (id 1337))







expects-err!

Syntax (expects-err! response-input thrown-value)

Input type:

Response(A,B), C

Output type:

B

The expects-err! function attempts to ‘unpack’ the first argument: if the argument is an (err ...) response, expects-err! returns the inner value of the err. If the supplied argument is an (ok ...) value, expects-err! returns thrown-value from the current function and exits the current control-flow.




Example

(expects-err! (err 1) 'false) ;; Returns 1







fetch-contract-entry

Syntax (fetch-contract-entry contract-name map-name key-tuple)

Input type:

ContractName, MapName, Tuple

Output type:

Optional(Tuple)

The fetch-contract-entry function looks up and returns an entry from a contract other than the current contract’s data map. The value is looked up using key-tuple. If there is no value associated with that key in the data map, the function returns a (none) option. Otherwise, it returns (some value).




Example

(expects! (fetch-contract-entry names-contract names-map (tuple (name "blockstack")) (err 1))) ;; Returns (tuple (id 1337))

(expects! (fetch-contract-entry names-contract names-map ((name "blockstack")) (err 1)));; Same command, using a shorthand for constructing the tuple







fetch-entry

Syntax (fetch-entry map-name key-tuple)

Input type:

MapName, Tuple

Output type:

Optional(Tuple)

The fetch-entry function looks up and returns an entry from a contract’s data map. The value is looked up using key-tuple. If there is no value associated with that key in the data map, the function returns a (none) option. Otherwise, it returns (some value)




Example

(expects! (fetch-entry names-map (tuple (name "blockstack"))) (err 1)) ;; Returns (tuple (id 1337))

(expects! (fetch-entry names-map ((name "blockstack"))) (err 1)) ;; Same command, using a shorthand for constructing the tuple







fetch-var

Syntax (fetch-var var-name)

Input type:

VarName

Output type:

A

The fetch-var function looks up and returns an entry from a contract’s data map. The value is looked up using var-name.




Example

(fetch-var cursor) ;; Returns cursor







filter

Syntax (filter func list)

Input type:

Function(A) -> bool, (list A)

Output type:

(list A)

The filter function applies the input function func to each element of the input list, and returns the same list with any elements removed for which the func returned false.




Example

(filter not (list true false true false)) ;; Returns (list false false)







fold

Syntax (fold func list initial-value)

Input type:

Function(A, B) -> B, (list A)

Output type:

B

The fold function applies the input function func to each element of the input list and the output of the previous application of the fold function. When invoked on the first list element, it uses the initial-value as the second input. fold returns the last value return by the successive applications.




Example

(fold * (list 2 2 2) 1) ;; Returns 8

(fold * (list 2 2 2) 0) ;; Returns 0







get-block-info

Syntax (get-block-info prop-name block-height-expr)

Input type:

BlockInfoPropertyName, BlockHeightInt

Output type:

buff | int

The get-block-info function fetches data for a block of the given block height. The value and type returned are determined by the specified BlockInfoPropertyName. If the provided BlockHeightInt does not correspond to an existing block, the function is aborted. The currently available property names are time, header-hash, burnchain-header-hash, and vrf-seed.

The time property returns an integer value of the block header time field. This is a Unix epoch timestamp in seconds which roughly corresponds to when the block was mined. Warning: this does not increase monotonically with each block and block times are accurate only to within two hours. See BIP113 for more information.

The header-hash, burnchain-header-hash, and vrf-seed properties return a 32-byte buffer.




Example

(get-block-info time 10) ;; Returns 1557860301

(get-block-info header-hash 2) ;; Returns 0x374708fff7719dd5979ec875d56cd2286f6d3cf7ec317a3b25632aab28ec37bb

(get-block-info vrf-seed 6) ;; Returns 0xf490de2920c8a35fabeb13208852aa28c76f9be9b03a4dd2b3c075f7a26923b4







get

Syntax (get key-name tuple)

Input type:

KeyName and Tuple | Optional(Tuple)

Output type:

AnyType

The get function fetches the value associated with a given key from the supplied typed tuple. If an Optional value is supplied as the inputted tuple, get returns an Optional type of the specified key in the tuple. If the supplied option is a (none) option, get returns (none).




Example

(get id (tuple (name "blockstack") (id 1337))) ;; Returns 1337

(get id (fetch-entry names-map (tuple (name "blockstack")))) ;; Returns (some 1337)

(get id (fetch-entry names-map (tuple (name "non-existent")))) ;; Returns (none)







hash160

Syntax (hash160 value)

Input type:

buff|int

Output type:

(buff 20)

The hash160 function computes RIPEMD160(SHA256(x)) of the inputted value. If an integer (128 bit) is supplied the hash is computed over the little-endian representation of the integer.




Example

(hash160 0) ;; Returns 0xe4352f72356db555721651aa612e00379167b30f







if

Syntax (if bool1 expr1 expr2)

Input type:

bool, A, A

Output type:

A

The if function admits a boolean argument and two expressions which must return the same type. In the case that the boolean input is true, the if function evaluates and returns expr1. If the boolean input is false, the if function evaluates and returns expr2.




Example

(if true 1 2) ;; Returns 1

(if (> 1 2) 1 2) ;; Returns 2







insert-entry!

Syntax (insert-entry! map-name key-tuple value-tuple)

Input type:

MapName, TupleA, TupleB

Output type:

bool

The insert-entry! function sets the value associated with the input key to the inputted value if and only if there is not already a value associated with the key in the map. If an insert occurs, the function returns true. If a value already existed for this key in the data map, the function returns false.




Example

(insert-entry! names-map (tuple (name "blockstack")) (tuple (id 1337))) ;; Returns 'true

(insert-entry! names-map (tuple (name "blockstack")) (tuple (id 1337))) ;; Returns 'false

(insert-entry! names-map ((name "blockstack")) ((id 1337))) ;; Same command, using a shorthand for constructing the tuple







is-none?

Syntax (is-none? value)

Input type:

Optional(A)

Output type:

bool

is-none? tests a supplied option value, returning true if the option value is (none), and false if it is a (some ...).




Example

(is-none? (get id (fetch-entry names-map (tuple (name "blockstack"))))) ;; Returns 'false

(is-none? (get id (fetch-entry names-map (tuple (name "non-existant"))))) ;; Returns 'true







is-ok?

Syntax (is-ok? value)

Input type:

Response(A,B)

Output type:

bool

is-ok? tests a supplied response value, returning true if the response was ok, and false if it was an err.




Example

(is-ok? (ok 1)) ;; Returns 'true

(is-ok? (err 1)) ;; Returns 'false







keccak256

Syntax (keccak256 value)

Input type:

buff|int

Output type:

(buff 32)

The keccak256 function computes KECCAK256(value) of the inputted value. Note that this differs from the NIST SHA-3 (that is, FIPS 202) standard. If an integer (128 bit) is supplied the hash is computed over the little-endian representation of the integer.




Example

(keccak256 0) ;; Returns 0xf490de2920c8a35fabeb13208852aa28c76f9be9b03a4dd2b3c075f7a26923b4







let

Syntax (let ((name1 expr1) (name2 expr2) ...) expr-body)

Input type:

((name2 AnyType) (name2 AnyType) ...), A

Output type:

A

The let function accepts a list of variable name and expression pairs, evaluating each expression and binding it to the corresponding variable name. The context created by this set of bindings is used for evaluating and return the value of expr-body.




Example

(let ((a 2) (b (+ 5 6 7))) (+ a b)) ;; Returns 20







list

Syntax (list expr1 expr2 expr3 ...)

Input type:

A, ...

Output type:

(list A)

The list function constructs a list composed of the inputted values. Each supplied value must be of the same type.




Example

(list (+ 1 2) 4 5) ;; Returns [3 4 5]







map

Syntax (map func list)

Input type:

Function(A) -> B, (list A)

Output type:

(list B)

The map function applies the input function func to each element of the input list, and outputs a list containing the outputs from those function applications.




Example

(map not (list true false true false)) ;; Returns 'false true false true







mod

Syntax (mod i1 i2)

Input type:

int, int

Output type:

int

Returns the integer remainder from integer dividing i1 by i2. In the event of a division by zero, throws a runtime error.




Example

(mod 2 3) ;; Returns 0

(mod 5 2) ;; Returns 1

(mod 7 1) ;; Returns 0







not

Syntax (not b1)

Input type:

bool

Output type:

bool

Returns the inverse of the boolean input.




Example

(not 'true) ;; Returns 'false

(not (eq? 1 2)) ;; Returns 'true







ok

Syntax (ok value)

Input type:

A

Output type:

Response(A,B)

The ok function constructs a response type from the input value. Use ok for creating return values in public functions. An ok value indicates that any database changes during the processing of the function should materialize.




Example

(ok 1) ;; Returns (ok 1)







or

Syntax (or b1 b2 ...)

Input type:

bool, ...

Output type:

bool

Returns true if any boolean inputs are true. Importantly, the supplied arguments are evaluated in-order and lazily. Lazy evaluation means that if one of the arguments returns false, the function short-circuits, and no subsequent arguments are evaluated.




Example

(or 'true 'false) ;; Returns 'true

(or (eq? (+ 1 2) 1) (eq? 4 4)) ;; Returns 'true

(or (eq? (+ 1 2) 1) (eq? 3 4)) ;; Returns 'false

(or (eq? (+ 1 2) 3) (eq? 4 4)) ;; Returns 'true







pow

Syntax (pow i1 i2)

Input type:

int, int

Output type:

int

Returns the result of raising i1 to the power of i2. In the event of an overflow, throws a runtime error.




Example

(pow 2 3) ;; Returns 8

(pow 2 2) ;; Returns 4

(pow 7 1) ;; Returns 7







print

Syntax (print expr)

Input type:

A

Output type:

A

The print function evaluates and returns its input expression. On Blockstack Core nodes configured for development (as opposed to production mining nodes), this function prints the resulting value to STDOUT (standard output).




Example

(print (+ 1 2 3)) ;; Returns 6







set-entry!

Syntax (set-entry! map-name key-tuple value-tuple)

Input type:

MapName, TupleA, TupleB

Output type:

bool

The set-entry! function sets the value associated with the input key to the inputted value. This function performs a blind update; whether or not a value is already associated with the key, the function overwrites that existing association.




Example

(set-entry! names-map (tuple (name "blockstack")) (tuple (id 1337))) ;; Returns 'true

(set-entry! names-map ((name "blockstack")) ((id 1337))) ;; Same command, using a shorthand for constructing the tuple







set-var!

Syntax (set-var! var-name expr1)

Input type:

VarName, AnyType

Output type:

bool

The set-var! function sets the value associated with the input variable to the inputted value.




Example

(set-var! cursor (+ cursor 1)) ;; Returns 'true







sha256

Syntax (sha256 value)

Input type:

buff|int

Output type:

(buff 32)

The sha256 function computes SHA256(x) of the inputted value. If an integer (128 bit) is supplied the hash is computed over the little-endian representation of the integer.




Example

(sha256 0) ;; Returns 0x374708fff7719dd5979ec875d56cd2286f6d3cf7ec317a3b25632aab28ec37bb







tuple

Syntax (tuple ((key0 expr0) (key1 expr1) ...))

Input type:

(list (KeyName AnyType))

Output type:

Tuple

The tuple function constructs a typed tuple from the supplied key and expression pairs. A get function can use typed tuples as input to select specific values from a given tuple. Key names may not appear multiple times in the same tuple definition. Supplied expressions are evaluated and associated with the expressions’ paired key name.




Example

(tuple (name "blockstack") (id 1337))







xor

Syntax (xor i1 i2)

Input type:

int, int

Output type:

int

Returns the result of bitwise exclusive or’ing i1 with i2.




Example

(xor 1 2) ;; Returns 3

(xor 120 280) ;; Returns 352
Continue Read »
Clarity language reference




This file contains the reference for the Clarity language.

Block Properties
Supported types

Int type
Bool type
Buffer type
List type
Principal type
Tuple type
Optional type
Response type

Native variables

block-height
contract-name
tx-sender

Clarity function reference

* (multiply)
+ (add)
- (subtract)
/ (divide)
< (less than)
<= (less than or equal)
> (greater than)
>= (greater than or equal)
and
as-contract
begin
contract-call!
default-to
define-data-var
define-map
define-public
define-read-only
define
delete-entry!
eq?
err
expects!
expects-err!
fetch-contract-entry
fetch-entry
fetch-var
filter
fold
get-block-info
get
hash160
if
insert-entry!
is-none?
is-ok?
keccak256
let
list
map
mod
not
ok
or
pow
print
set-entry!
set-var!
sha256
tuple
xor




Block Properties

The get-block-info function fetches property details for a block at a specified block height. For example:

(get-block-info time 10) ;; Returns 1557860301

Because the Clarity language is in pre-release, the block properties that are fetched are simulated properties from a SQLite database. The available property names are:

Property

Definition

header-hash

A 32-byte buffer containing the block hash.

burnchain-header-hash

A 32-byte buffer that contains the hash from the proof of burn.

vrf-seed

A 32-byte buffer containing the Verifiable Random Function (VRF) seed value used for the block.

time

An integer value containing that roughly corresponds to when the block was mined. This is a Unix epoch timestamp in seconds.

Warning: The time does not increase monotonically with each block. Block times are accurate only to within two hours. See BIP113 for more information.




Supported types

This section lists the types available to smart contracts. The only atomic types supported by the Clarity are booleans, integers, fixed length buffers, and principals.




Int type

The integer type in the Clarity language is a 16-byte signed integer, which allows it to specify the maximum amount of microstacks spendable in a single Stacks transfer. The special BlockHeightInt you can obtain with the get-block-info function.




Bool type

Supports values of 'true or 'false.




Buffer type

Buffer types represent fixed-length byte buffers. Currently, the only way to construct a Buffer is using string literals, for example "alice.id" or hash160("bob.id")

All of the hash functions return buffers:

hash160 sha256 keccak256

The block properties header-hash, burnchain-header-hash, and vrf-seed are all buffers.




List type

Clarity supports lists of the atomic types. However, the only variable length lists in the language appear as function inputs; there is no support for list operations like append or join.




Principal type

Clarity provides this primitive for checking whether or not the smart contract transaction was signed by a particular principal. Principals represent a spending entity and are roughly equivalent to a Stacks address. The principal’s signature is not checked by the smart contract, but by the virtual machine. A smart contract function can use the globally defined tx-sender variable to obtain the current principal.

Smart contracts may also be principals (represented by the smart contract’s identifier). However, there is no private key associated with the smart contract, and it cannot broadcast a signed transaction on the blockchain. A smart contract uses the special variable contract-name to refer to its own principal.




Tuple type

To support the use of named fields in keys and values, Clarity allows the construction of named tuples using a function (tuple ...), for example

(define imaginary-number-a (tuple (real 1) (i 2)))

(define imaginary-number-b (tuple (real 2) (i 3)))

This allows for creating named tuples on the fly, which is useful for data maps where the keys and values are themselves named tuples. Values in a given mapping are set or fetched using:

Function

Description

(fetch-entry map-name key-tuple)

Fetches the value associated with a given key in the map, or returns none if there is no such value.

(set-entry! map-name key-tuple value-tuple)

Sets the value of key-tuple in the data map

(insert-entry! map-name key-tuple value-tuple)

Sets the value of key-tuple in the data map if and only if an entry does not already exist.

(delete-entry! map-name key-tuple)

Deletes key-tuple from the data map.

To access a named value of a given tuple, the (get name tuple) function returns that item from the tuple.




Optional type

Represents an optional value. This is used in place of the typical usage of “null” values in other languages, and represents a type that can either be some value or none. Optional types are used as the return types of data-map functions.




Response type

Response types represent the result of a public function. Use this type to indicate and return data associated with the execution of the function. Also, the response should indicate whether the function error’ed (and therefore did not materialize any data in the database) or ran ok (in which case data materialized in the database).

Response types contain two subtypes – a response type in the event of ok (that is, a public function returns an integer code on success) and an err type (that is, a function returns a buffer on error).




Native variables

The Clarity language includes native variables you can use in your contract.




block-height

The height of a block in the Stacks blockchain. Block height is the number of blocks in the chain between any given block and the very first block in the blockchain. You can obtain a block-height via the get-block-info function.




contract-name

Represents the current contract.




tx-sender

Represents the current principal. This variable does not change during inter-contract calls. This means that if a transaction invokes a function in a given smart contract, that function is able to make calls into other smart contracts on your behalf. This enables a wide variety of applications, but it comes with some dangers for users of smart contracts. Static analysis of Clarity contracts guarantees the language allows clients to deduce which functions a given smart contract will ever call. Good clients should always warn users about any potential side effects of a given transaction.




Clarity function reference




* (multiply)

Syntax (* i1 i2...)

Input type:

int, ...

Output type:

int

Multiplies a variable number of integer inputs and returns the result. In the event of an overflow, throws a runtime error.




Example

(* 2 3) ;; Returns 6

(* 5 2) ;; Returns 10

(* 2 2 2) ;; Returns 8







+ (add)

Syntax (+ i1 i2...)

Input type:

int, ...

Output type:

int

Adds a variable number of integer inputs and returns the result. In the event of an overflow, throws a runtime error.




Example

(+ 1 2 3) ;; Returns 6







- (subtract)

Syntax (- i1 i2...)

Input type:

int, ...

Output type:

int

Subtracts a variable number of integer inputs and returns the result. In the event of an underflow, throws a runtime error.




Example

(- 2 1 1) ;; Returns 0

(- 0 3) ;; Returns -3







/ (divide)

Syntax (/ i1 i2...)

Input type:

int, ...

Output type:

int

Integer divides a variable number of integer inputs and returns the result. In the event of division by zero, throws a runtime error.




Example

(/ 2 3) ;; Returns 0

(/ 5 2) ;; Returns 2

(/ 4 2 2) ;; Returns 1







< (less than)

Syntax (< i1 i2)

Input type:

int, int

Output type:

bool

Compares two integers, returning true if i1 is less than i2 and false otherwise.




Example

(< 1 2) ;; Returns 'true

(< 5 2) ;; Returns 'false







<= (less than or equal)

Syntax (> i1 i2)

Input type:

int, int

Output type:

bool

Compares two integers, returning true if i1 is less than or equal to i2 and false otherwise.




Example

(<= 1 1) ;; Returns 'true

(<= 5 2) ;; Returns 'false







> (greater than)

Syntax (> i1 i2)

Input type:

int, int

Output type:

bool

Compares two integers, returning true if i1 is greater than i2 and false otherwise.




Example

(> 1 2) ;; Returns 'false

(> 5 2) ;; Returns 'true







>= (greater than or equal)

Syntax (>= i1 i2)

Input type:

int, int

Output type:

bool

Compares two integers, returning true if i1 is greater than or equal to i2 and false otherwise.




Example

(>= 1 1) ;; Returns 'true

(>= 5 2) ;; Returns 'true







and

Syntax (and b1 b2 ...)

Input type:

bool, ...

Output type:

bool

Returns true if all boolean inputs are true. Importantly, the supplied arguments are evaluated in-order and lazily. Lazy evaluation means that if one of the arguments returns false, the function short-circuits, and no subsequent arguments are evaluated.




Example

(and 'true 'false) ;; Returns 'false

(and (eq? (+ 1 2) 1) (eq? 4 4)) ;; Returns 'false

(and (eq? (+ 1 2) 3) (eq? 4 4)) ;; Returns 'true







as-contract

Syntax (as-contract expr)

Input type:

A

Output type:

A

The as-contract function switches the current context’s tx-sender value to the contract’s principal and executes expr with that context. It returns the resulting value of expr.




Example

(as-contract (print tx-sender)) ;; Returns 'CTcontract.name







begin

Syntax (begin expr1 expr2 expr3 ... expr-last)

Input type:

AnyType, ... A

Output type:

A

The begin function evaluates each of its input expressions, returning the return value of the last such expression.




Example

(begin (+ 1 2) 4 5) ;; Returns 5







contract-call!

Syntax (contract-call! contract-name function-name arg0 arg1 ...)

Input type:

ContractName, PublicFunctionName, Arg0, ...

Output type:

Response(A,B)

The contract-call! function executes the given public function of the given contract. You may not this function to call a public function defined in the current contract. If the public function returns err, any database changes resulting from calling contract-call! are aborted. If the function returns ok, database changes occurred.




Example

(contract-call! tokens transfer 'SZ2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKQ9H6DPR 19) ;; Returns (ok 1)







default-to

Syntax (default-to default-value option-value)

Input type:

A, Optional(A)

Output type:

A

The default-to function attempts to ‘unpack’ the second argument: if the argument is a (some ...) option, it returns the inner value of the option. If the second argument is a (none) value, default-to it returns the value of default-value.




Example

(default-to 0 (get id (fetch-entry names-map (tuple (name "blockstack"))))) ;; Returns 1337

(default-to 0 (get id (fetch-entry names-map (tuple (name "non-existant"))))) ;; Returns 0







define-data-var

Syntax (define-data-var var-name type value)

Input type:

VarName, TypeDefinition, Value

Output type:

Not Applicable

define-data-var is used to define a new persisted variable for use in a smart contract. Such variable are only modifiable by the current smart contract.

Persisted variable are defined with a type and a value.

Like other kinds of definition statements, define-data-var may only be used at the top level of a smart contract definition (i.e., you cannot put a define statement in the middle of a function body).




Example

(define-data-var size int 0)

(define (set-size (value int))

  (set-var! size value))

(set-size 1)

(set-size 2)







define-map

Syntax (define-map map-name ((key-name-0 key-type-0) ...) ((val-name-0 val-type-0) ...))

Input type:

MapName, KeyTupleDefinition, MapTupleDefinition

Output type:

Not Applicable

define-map is used to define a new datamap for use in a smart contract. Such maps are only modifiable by the current smart contract.

Maps are defined with a key tuple type and value tuple type. These are defined using a list of name and type pairs, e.g., a key type might be ((id int)), which is a tuple with a single “id” field of type int.

Like other kinds of definition statements, define-map may only be used at the top level of a smart contract definition (i.e., you cannot put a define statement in the middle of a function body).




Example

(define-map squares ((x int)) ((square int)))

(define (add-entry (x int))

  (insert-entry! squares ((x 2)) ((square (* x x)))))

(add-entry 1)

(add-entry 2)

(add-entry 3)

(add-entry 4)

(add-entry 5)







define-public

Syntax (define-public (function-name (arg-name-0 arg-type-0) (arg-name-1 arg-type-1) ...) function-body)

Input type:

MethodSignature, MethodBody

Output type:

Not Applicable

define-public is used to define a public function and transaction for a smart contract. Public functions are callable from other smart contracts and may be invoked directly by users by submitting a transaction to the Stacks blockchain.

Like other kinds of definition statements, define-public may only be used at the top level of a smart contract definition (i.e., you cannot put a define statement in the middle of a function body).

Public functions must return a ResponseType (using either ok or err). Any datamap modifications performed by a public function is aborted if the function returns an err type. Public functions may be invoked by other contracts via contract-call!.




Example

(define-public (hello-world (input int))

  (begin (print (+ 2 input))

         (ok input)))







define-read-only

Syntax (define-read-only (function-name (arg-name-0 arg-type-0) (arg-name-1 arg-type-1) ...) function-body)

Input type:

MethodSignature, MethodBody

Output type:

Not Applicable

define-read-only is used to define a public read-only function for a smart contract. Such functions are callable from other smart contracts.

Like other kinds of definition statements, define-read-only may only be used at the top level of a smart contract definition (i.e., you cannot put a define statement in the middle of a function body).

Read-only functions may return any type. However, read-only functions may not perform any datamap modifications, or call any functions which perform such modifications. This is enforced both during type checks and during the execution of the function. Public read-only functions may be invoked by other contracts via contract-call!.




Example

(define-read-only (just-return-one-hundred)

  (* 10 10))







define

Syntax (define (function-name (arg-name-0 arg-type-0) (arg-name-1 arg-type-1) ...) function-body)

Input type:

MethodSignature, MethodBody

Output type:

Not Applicable

define is used to define private functions for a smart contract. Private functions may not be called from other smart contracts, nor may they be invoked directly by users. Instead, these functions may only be invoked by other functions defined in the same smart contract.

Like other kinds of definition statements, define may only be used at the top level of a smart contract definition (i.e., you cannot put a define statement in the middle of a function body).

Private functions may return any type.




Example

(define (max-of (i1 int) (i2 int))

  (if (> i1 i2)

      i1

      i2))

(max-of 4 6) ;; returns 6







delete-entry!

Syntax (delete-entry! map-name key-tuple)

Input type:

MapName, Tuple

Output type:

bool

The delete-entry! function removes the value associated with the input key for the given map. If an item exists and is removed, the function returns true. If a value did not exist for this key in the data map, the function returns false.




Example

(delete-entry! names-map (tuple (name "blockstack"))) ;; Returns 'true

(delete-entry! names-map (tuple (name "blockstack"))) ;; Returns 'false

(delete-entry! names-map ((name "blockstack"))) ;; Same command, using a shorthand for constructing the tuple







eq?

Syntax (eq? v1 v2...)

Input type:

A, A, ...

Output type:

bool

Compares the inputted values, returning true if they are all equal. Note that unlike the (and ...) function, (eq? ...) will not short-circuit.




Example

(eq? 1 1) ;; Returns 'true

(eq? 1 'false) ;; Returns 'false

(eq? "abc" 234 234) ;; Returns 'false







err

Syntax (err value)

Input type:

A

Output type:

Response(A,B)

The err function constructs a response type from the input value. Use err for creating return values in public functions. An err value indicates that any database changes during the processing of the function should be rolled back.




Example

(err 'true) ;; Returns (err 'true)







expects!

Syntax (expects! option-input thrown-value)

Input type:

Optional(A) | Response(A,B), C

Output type:

A

The expects! function attempts to ‘unpack’ the first argument: if the argument is an option type, and the argument is a (some ...) option, expects! returns the inner value of the option. If the argument is a response type, and the argument is an (ok ...) response, expects! returns the inner value of the ok. If the supplied argument is either an (err ...) or a (none) value, expects! returns thrown-value from the current function and exits the current control-flow.




Example

(expects! (fetch-entry names-map (tuple (name "blockstack"))) (err 1)) ;; Returns (tuple (id 1337))







expects-err!

Syntax (expects-err! response-input thrown-value)

Input type:

Response(A,B), C

Output type:

B

The expects-err! function attempts to ‘unpack’ the first argument: if the argument is an (err ...) response, expects-err! returns the inner value of the err. If the supplied argument is an (ok ...) value, expects-err! returns thrown-value from the current function and exits the current control-flow.




Example

(expects-err! (err 1) 'false) ;; Returns 1







fetch-contract-entry

Syntax (fetch-contract-entry contract-name map-name key-tuple)

Input type:

ContractName, MapName, Tuple

Output type:

Optional(Tuple)

The fetch-contract-entry function looks up and returns an entry from a contract other than the current contract’s data map. The value is looked up using key-tuple. If there is no value associated with that key in the data map, the function returns a (none) option. Otherwise, it returns (some value).




Example

(expects! (fetch-contract-entry names-contract names-map (tuple (name "blockstack")) (err 1))) ;; Returns (tuple (id 1337))

(expects! (fetch-contract-entry names-contract names-map ((name "blockstack")) (err 1)));; Same command, using a shorthand for constructing the tuple







fetch-entry

Syntax (fetch-entry map-name key-tuple)

Input type:

MapName, Tuple

Output type:

Optional(Tuple)

The fetch-entry function looks up and returns an entry from a contract’s data map. The value is looked up using key-tuple. If there is no value associated with that key in the data map, the function returns a (none) option. Otherwise, it returns (some value)




Example

(expects! (fetch-entry names-map (tuple (name "blockstack"))) (err 1)) ;; Returns (tuple (id 1337))

(expects! (fetch-entry names-map ((name "blockstack"))) (err 1)) ;; Same command, using a shorthand for constructing the tuple







fetch-var

Syntax (fetch-var var-name)

Input type:

VarName

Output type:

A

The fetch-var function looks up and returns an entry from a contract’s data map. The value is looked up using var-name.




Example

(fetch-var cursor) ;; Returns cursor







filter

Syntax (filter func list)

Input type:

Function(A) -> bool, (list A)

Output type:

(list A)

The filter function applies the input function func to each element of the input list, and returns the same list with any elements removed for which the func returned false.




Example

(filter not (list true false true false)) ;; Returns (list false false)







fold

Syntax (fold func list initial-value)

Input type:

Function(A, B) -> B, (list A)

Output type:

B

The fold function applies the input function func to each element of the input list and the output of the previous application of the fold function. When invoked on the first list element, it uses the initial-value as the second input. fold returns the last value return by the successive applications.




Example

(fold * (list 2 2 2) 1) ;; Returns 8

(fold * (list 2 2 2) 0) ;; Returns 0







get-block-info

Syntax (get-block-info prop-name block-height-expr)

Input type:

BlockInfoPropertyName, BlockHeightInt

Output type:

buff | int

The get-block-info function fetches data for a block of the given block height. The value and type returned are determined by the specified BlockInfoPropertyName. If the provided BlockHeightInt does not correspond to an existing block, the function is aborted. The currently available property names are time, header-hash, burnchain-header-hash, and vrf-seed.

The time property returns an integer value of the block header time field. This is a Unix epoch timestamp in seconds which roughly corresponds to when the block was mined. Warning: this does not increase monotonically with each block and block times are accurate only to within two hours. See BIP113 for more information.

The header-hash, burnchain-header-hash, and vrf-seed properties return a 32-byte buffer.




Example

(get-block-info time 10) ;; Returns 1557860301

(get-block-info header-hash 2) ;; Returns 0x374708fff7719dd5979ec875d56cd2286f6d3cf7ec317a3b25632aab28ec37bb

(get-block-info vrf-seed 6) ;; Returns 0xf490de2920c8a35fabeb13208852aa28c76f9be9b03a4dd2b3c075f7a26923b4







get

Syntax (get key-name tuple)

Input type:

KeyName and Tuple | Optional(Tuple)

Output type:

AnyType

The get function fetches the value associated with a given key from the supplied typed tuple. If an Optional value is supplied as the inputted tuple, get returns an Optional type of the specified key in the tuple. If the supplied option is a (none) option, get returns (none).




Example

(get id (tuple (name "blockstack") (id 1337))) ;; Returns 1337

(get id (fetch-entry names-map (tuple (name "blockstack")))) ;; Returns (some 1337)

(get id (fetch-entry names-map (tuple (name "non-existent")))) ;; Returns (none)







hash160

Syntax (hash160 value)

Input type:

buff|int

Output type:

(buff 20)

The hash160 function computes RIPEMD160(SHA256(x)) of the inputted value. If an integer (128 bit) is supplied the hash is computed over the little-endian representation of the integer.




Example

(hash160 0) ;; Returns 0xe4352f72356db555721651aa612e00379167b30f







if

Syntax (if bool1 expr1 expr2)

Input type:

bool, A, A

Output type:

A

The if function admits a boolean argument and two expressions which must return the same type. In the case that the boolean input is true, the if function evaluates and returns expr1. If the boolean input is false, the if function evaluates and returns expr2.




Example

(if true 1 2) ;; Returns 1

(if (> 1 2) 1 2) ;; Returns 2







insert-entry!

Syntax (insert-entry! map-name key-tuple value-tuple)

Input type:

MapName, TupleA, TupleB

Output type:

bool

The insert-entry! function sets the value associated with the input key to the inputted value if and only if there is not already a value associated with the key in the map. If an insert occurs, the function returns true. If a value already existed for this key in the data map, the function returns false.




Example

(insert-entry! names-map (tuple (name "blockstack")) (tuple (id 1337))) ;; Returns 'true

(insert-entry! names-map (tuple (name "blockstack")) (tuple (id 1337))) ;; Returns 'false

(insert-entry! names-map ((name "blockstack")) ((id 1337))) ;; Same command, using a shorthand for constructing the tuple







is-none?

Syntax (is-none? value)

Input type:

Optional(A)

Output type:

bool

is-none? tests a supplied option value, returning true if the option value is (none), and false if it is a (some ...).




Example

(is-none? (get id (fetch-entry names-map (tuple (name "blockstack"))))) ;; Returns 'false

(is-none? (get id (fetch-entry names-map (tuple (name "non-existant"))))) ;; Returns 'true







is-ok?

Syntax (is-ok? value)

Input type:

Response(A,B)

Output type:

bool

is-ok? tests a supplied response value, returning true if the response was ok, and false if it was an err.




Example

(is-ok? (ok 1)) ;; Returns 'true

(is-ok? (err 1)) ;; Returns 'false







keccak256

Syntax (keccak256 value)

Input type:

buff|int

Output type:

(buff 32)

The keccak256 function computes KECCAK256(value) of the inputted value. Note that this differs from the NIST SHA-3 (that is, FIPS 202) standard. If an integer (128 bit) is supplied the hash is computed over the little-endian representation of the integer.




Example

(keccak256 0) ;; Returns 0xf490de2920c8a35fabeb13208852aa28c76f9be9b03a4dd2b3c075f7a26923b4







let

Syntax (let ((name1 expr1) (name2 expr2) ...) expr-body)

Input type:

((name2 AnyType) (name2 AnyType) ...), A

Output type:

A

The let function accepts a list of variable name and expression pairs, evaluating each expression and binding it to the corresponding variable name. The context created by this set of bindings is used for evaluating and return the value of expr-body.




Example

(let ((a 2) (b (+ 5 6 7))) (+ a b)) ;; Returns 20







list

Syntax (list expr1 expr2 expr3 ...)

Input type:

A, ...

Output type:

(list A)

The list function constructs a list composed of the inputted values. Each supplied value must be of the same type.




Example

(list (+ 1 2) 4 5) ;; Returns [3 4 5]







map

Syntax (map func list)

Input type:

Function(A) -> B, (list A)

Output type:

(list B)

The map function applies the input function func to each element of the input list, and outputs a list containing the outputs from those function applications.




Example

(map not (list true false true false)) ;; Returns 'false true false true







mod

Syntax (mod i1 i2)

Input type:

int, int

Output type:

int

Returns the integer remainder from integer dividing i1 by i2. In the event of a division by zero, throws a runtime error.




Example

(mod 2 3) ;; Returns 0

(mod 5 2) ;; Returns 1

(mod 7 1) ;; Returns 0







not

Syntax (not b1)

Input type:

bool

Output type:

bool

Returns the inverse of the boolean input.




Example

(not 'true) ;; Returns 'false

(not (eq? 1 2)) ;; Returns 'true







ok

Syntax (ok value)

Input type:

A

Output type:

Response(A,B)

The ok function constructs a response type from the input value. Use ok for creating return values in public functions. An ok value indicates that any database changes during the processing of the function should materialize.




Example

(ok 1) ;; Returns (ok 1)







or

Syntax (or b1 b2 ...)

Input type:

bool, ...

Output type:

bool

Returns true if any boolean inputs are true. Importantly, the supplied arguments are evaluated in-order and lazily. Lazy evaluation means that if one of the arguments returns false, the function short-circuits, and no subsequent arguments are evaluated.




Example

(or 'true 'false) ;; Returns 'true

(or (eq? (+ 1 2) 1) (eq? 4 4)) ;; Returns 'true

(or (eq? (+ 1 2) 1) (eq? 3 4)) ;; Returns 'false

(or (eq? (+ 1 2) 3) (eq? 4 4)) ;; Returns 'true







pow

Syntax (pow i1 i2)

Input type:

int, int

Output type:

int

Returns the result of raising i1 to the power of i2. In the event of an overflow, throws a runtime error.




Example

(pow 2 3) ;; Returns 8

(pow 2 2) ;; Returns 4

(pow 7 1) ;; Returns 7







print

Syntax (print expr)

Input type:

A

Output type:

A

The print function evaluates and returns its input expression. On Blockstack Core nodes configured for development (as opposed to production mining nodes), this function prints the resulting value to STDOUT (standard output).




Example

(print (+ 1 2 3)) ;; Returns 6







set-entry!

Syntax (set-entry! map-name key-tuple value-tuple)

Input type:

MapName, TupleA, TupleB

Output type:

bool

The set-entry! function sets the value associated with the input key to the inputted value. This function performs a blind update; whether or not a value is already associated with the key, the function overwrites that existing association.




Example

(set-entry! names-map (tuple (name "blockstack")) (tuple (id 1337))) ;; Returns 'true

(set-entry! names-map ((name "blockstack")) ((id 1337))) ;; Same command, using a shorthand for constructing the tuple







set-var!

Syntax (set-var! var-name expr1)

Input type:

VarName, AnyType

Output type:

bool

The set-var! function sets the value associated with the input variable to the inputted value.




Example

(set-var! cursor (+ cursor 1)) ;; Returns 'true







sha256

Syntax (sha256 value)

Input type:

buff|int

Output type:

(buff 32)

The sha256 function computes SHA256(x) of the inputted value. If an integer (128 bit) is supplied the hash is computed over the little-endian representation of the integer.




Example

(sha256 0) ;; Returns 0x374708fff7719dd5979ec875d56cd2286f6d3cf7ec317a3b25632aab28ec37bb







tuple

Syntax (tuple ((key0 expr0) (key1 expr1) ...))

Input type:

(list (KeyName AnyType))

Output type:

Tuple

The tuple function constructs a typed tuple from the supplied key and expression pairs. A get function can use typed tuples as input to select specific values from a given tuple. Key names may not appear multiple times in the same tuple definition. Supplied expressions are evaluated and associated with the expressions’ paired key name.




Example

(tuple (name "blockstack") (id 1337))







xor

Syntax (xor i1 i2)

Input type:

int, int

Output type:

int

Returns the result of bitwise exclusive or’ing i1 with i2.




Example

(xor 1 2) ;; Returns 3

(xor 120 280) ;; Returns 352 Collapse Read »

Quickstart for the SDK

You can use the software developer kit (SDK) to develop, test, and deploy Clarity smart contracts. The SDK goes beyond the basic test environment to allow for development of Javascript or TypeScript clients that call upon Clarity contracts.


About this tutorial and the prerequisites you need
Task 1: Generate an initial Clarity project
Task 2: Investigate the generated project
Task 3: Try to expand the contract


 
About this tutorial and the prerequisites you need
 
Note: This tutorial was written on macOS High Sierra 10.13.4. If you use a Windows or Linux system, you can still follow along. However, you will need to "translate" appropriately for your operating system.
 
 
For this tutorial, you will use npm to manage dependencies and scripts. The tutorial relies on the npm dependency manager. Before you begin, verify you have installed npm using the which command to verify.
 
$ which npm
/usr/local/bin/npm

If you don’t find npm in your system, install it.

You use npm to install Yeoman. Yeoman is a generic scaffolding system that helps users rapidly start new projects and streamline the maintenance of existing projects. Verify you have installed yo using the which command.
 
$ which yo
/usr/local/bin/yo

 
If you don’t have Yeoman, you can install it with the npm install -g yo command.
 
Task 1: Generate an initial Clarity project

The SDK uses Yeoman to generate a project scaffold — an initial set of directories and files.

1. Create a new directory for your project.
 
 mkdir hello-clarity-sdk
2. Change into your new project directory.
cd hello-clarity-sdk
3. Use the npm command to initialize a Clarity project.
 
npm init yo clarity-dev npx: installed 15 in 1.892s create package.json create .vscode/extensions.json ... Project created at /private/tmp/hello-clarity-sdk ✔ create-yo ok!
Depending on your connection speed, it may take time to construct the scaffolding.
 
Task 2: Investigate the generated project
 
Your project should contain three directories:
 

 
 
The contracts directory contains a single file in sample/hello-world.clar file.
 
(define (hello-world)
"hello world")

(define (echo-number (val int))
val)


 
The contract exposes 2 rudimentary functions. The say-hi returns a hello world string. The increment-number: echos val.

The project also includes tests/hello-world.ts file. The test is written in Typescript. You can also write tests in Javascript.
 
 
import { Client, Provider, ProviderRegistry, Result } from "@blockstack/clarity";
import { assert } from "chai";

describe("hello world contract test suite", () => {
let helloWorldClient: Client;
let provider: Provider;

before(async () => {
provider = await ProviderRegistry.createProvider();
helloWorldClient = new Client("hello-world", "sample/hello-world", provider);
});

it("should have a valid syntax", async () => {
await helloWorldClient.checkContract();
});

describe("deploying an instance of the contract", () => {
before(async () => {
await helloWorldClient.deployContract();
});

it("should print hello world message", async () => {
const query = helloWorldClient.createQuery({ method: { name: "hello-world", args: } });
const receipt = await helloWorldClient.submitQuery(query);
const result = Result.unwrap(receipt);
const parsedResult = Buffer.from(result.replace("0x", ""), "hex").toString();
assert.equal(parsedResult, "hello world");
});

it("should echo number", async () => {
const query = helloWorldClient.createQuery({
method: { name: "echo-number", args: ["123"] }
});
const receipt = await helloWorldClient.submitQuery(query);
const result = Result.unwrap(receipt);
assert.equal(result, "123");
});
});

after(async () => {
await provider.close();
});
});

 
 
The hello-world.ts test file is a client that runs the hello-world.clar contract. Tests are critical for smart contracts as they are intended to manipulate assets and their ownership. These manipulations are irreversible within a blockchain. As you create a contracts, you should not be surprise if you end up spending more time and having more code in your tests than in your contracts directory. The tests/hello-world.ts file in the scaffold has the following content:

The first part of the test (lines 1 -10) sets up the test environment. It defines a Clarity provider and launches it (line 9). The Client instance contains a contract name and the path to the sample code. This test also checks the client (line 14) and then launches it (line 19), this is equivalent to running clarity-cli check with the command line. The remaining test code exercises the contract. Try running this test.
 
npm run test

> [email protected] test /private/tmp/hello-clarity-sdk
> mocha



hello world contract test suite
✓ should have a valid syntax
deploying an instance of the contract
✓ should print hello world message
✓ should echo number


3 passing (182ms)

 
In the next section, try your hand at expanding the hello-world.clar program.
 
Task 3: Try to expand the contract

In this task, you are challenged to expand the contents of the contracts/hello-world.clar file. Use your favorite editor and open the contracts/hello-world.clar file. If you use Visual Studio Code, you can install the Blockstack Clarity extension. The extension provides syntax coloration and some autocompletion.

Edit the hello-world.clar file.
 
;; Functions

(define (hello-world)
"hello world")

(define (echo-number (val int))
val)


Use the + function to create a increment-number-by-10 function.
 
answer:
 
;; Functions

(define (say-hi)
"hello world")

(define (increment-number (number int))
(+ 1 number))

(define (increment-number-by-10 (number int))
(+ 10 number))


Use the + and - function to create a decrement-number user-defined method.
 
 
answer:
 ;; Functions

(define (say-hi)
"hello world")

(define (increment-number (number int))
(+ 1 number))

(define (increment-number-by-10 (number int))
(+ 10 number))

(define (decrement-number (number int))
(- number 1))
Finally, try adding a counter variable and be sure to store it. Increment counter in your code and add a get-counter funtion to return the result. Here is a hint, you can add a var` to a contract by adding the following line (before the function):
 
 

```cl ;; Storage (define-data-var internal-value int 0)
 
 
 
answer:
 
 
;; Storage

(define-data-var counter int 0)

;; Functions

(define (say-hi)
"hello world")

(define (increment-number (number int))
(+ 1 number))

(define (increment-number-by-10 (number int))
(+ 10 number))

(define (decrement-number (number int))
(- number 1))

(define (increment-counter)
(set-var! counter (+ 1 counter)))

(define (get-counter)
(counter))

 
To review other, longer sample programs visit the ]clarity-js-sdk[/url] repository.
 
 
 
Continue Read »
You can use the software developer kit (SDK) to develop, test, and deploy Clarity smart contracts. The SDK goes beyond the basic test environment to allow for development of Javascript or TypeScript clients that call upon Clarity contracts.


About this tutorial and the prerequisites you need
Task 1: Generate an initial Clarity project
Task 2: Investigate the generated project
Task 3: Try to expand the contract


 
About this tutorial and the prerequisites you need
 
Note: This tutorial was written on macOS High Sierra 10.13.4. If you use a Windows or Linux system, you can still follow along. However, you will need to "translate" appropriately for your operating system.
 
 
For this tutorial, you will use npm to manage dependencies and scripts. The tutorial relies on the npm dependency manager. Before you begin, verify you have installed npm using the which command to verify.
 
$ which npm
/usr/local/bin/npm

If you don’t find npm in your system, install it.

You use npm to install Yeoman. Yeoman is a generic scaffolding system that helps users rapidly start new projects and streamline the maintenance of existing projects. Verify you have installed yo using the which command.
 
$ which yo
/usr/local/bin/yo

 
If you don’t have Yeoman, you can install it with the npm install -g yo command.
 
Task 1: Generate an initial Clarity project

The SDK uses Yeoman to generate a project scaffold — an initial set of directories and files.

1. Create a new directory for your project.
 
 mkdir hello-clarity-sdk
2. Change into your new project directory.
cd hello-clarity-sdk
3. Use the npm command to initialize a Clarity project.
 
npm init yo clarity-dev npx: installed 15 in 1.892s create package.json create .vscode/extensions.json ... Project created at /private/tmp/hello-clarity-sdk ✔ create-yo ok!
Depending on your connection speed, it may take time to construct the scaffolding.
 
Task 2: Investigate the generated project
 
Your project should contain three directories:
 

 
 
The contracts directory contains a single file in sample/hello-world.clar file.
 
(define (hello-world)
"hello world")

(define (echo-number (val int))
val)


 
The contract exposes 2 rudimentary functions. The say-hi returns a hello world string. The increment-number: echos val.

The project also includes tests/hello-world.ts file. The test is written in Typescript. You can also write tests in Javascript.
 
 
import { Client, Provider, ProviderRegistry, Result } from "@blockstack/clarity";
import { assert } from "chai";

describe("hello world contract test suite", () => {
let helloWorldClient: Client;
let provider: Provider;

before(async () => {
provider = await ProviderRegistry.createProvider();
helloWorldClient = new Client("hello-world", "sample/hello-world", provider);
});

it("should have a valid syntax", async () => {
await helloWorldClient.checkContract();
});

describe("deploying an instance of the contract", () => {
before(async () => {
await helloWorldClient.deployContract();
});

it("should print hello world message", async () => {
const query = helloWorldClient.createQuery({ method: { name: "hello-world", args: } });
const receipt = await helloWorldClient.submitQuery(query);
const result = Result.unwrap(receipt);
const parsedResult = Buffer.from(result.replace("0x", ""), "hex").toString();
assert.equal(parsedResult, "hello world");
});

it("should echo number", async () => {
const query = helloWorldClient.createQuery({
method: { name: "echo-number", args: ["123"] }
});
const receipt = await helloWorldClient.submitQuery(query);
const result = Result.unwrap(receipt);
assert.equal(result, "123");
});
});

after(async () => {
await provider.close();
});
});

 
 
The hello-world.ts test file is a client that runs the hello-world.clar contract. Tests are critical for smart contracts as they are intended to manipulate assets and their ownership. These manipulations are irreversible within a blockchain. As you create a contracts, you should not be surprise if you end up spending more time and having more code in your tests than in your contracts directory. The tests/hello-world.ts file in the scaffold has the following content:

The first part of the test (lines 1 -10) sets up the test environment. It defines a Clarity provider and launches it (line 9). The Client instance contains a contract name and the path to the sample code. This test also checks the client (line 14) and then launches it (line 19), this is equivalent to running clarity-cli check with the command line. The remaining test code exercises the contract. Try running this test.
 
npm run test

> [email protected] test /private/tmp/hello-clarity-sdk
> mocha



hello world contract test suite
✓ should have a valid syntax
deploying an instance of the contract
✓ should print hello world message
✓ should echo number


3 passing (182ms)

 
In the next section, try your hand at expanding the hello-world.clar program.
 
Task 3: Try to expand the contract

In this task, you are challenged to expand the contents of the contracts/hello-world.clar file. Use your favorite editor and open the contracts/hello-world.clar file. If you use Visual Studio Code, you can install the Blockstack Clarity extension. The extension provides syntax coloration and some autocompletion.

Edit the hello-world.clar file.
 
;; Functions

(define (hello-world)
"hello world")

(define (echo-number (val int))
val)


Use the + function to create a increment-number-by-10 function.
 
answer:
 
;; Functions

(define (say-hi)
"hello world")

(define (increment-number (number int))
(+ 1 number))

(define (increment-number-by-10 (number int))
(+ 10 number))


Use the + and - function to create a decrement-number user-defined method.
 
 
answer:
 ;; Functions

(define (say-hi)
"hello world")

(define (increment-number (number int))
(+ 1 number))

(define (increment-number-by-10 (number int))
(+ 10 number))

(define (decrement-number (number int))
(- number 1))
Finally, try adding a counter variable and be sure to store it. Increment counter in your code and add a get-counter funtion to return the result. Here is a hint, you can add a var` to a contract by adding the following line (before the function):
 
 

```cl ;; Storage (define-data-var internal-value int 0)
 
 
 
answer:
 
 
;; Storage

(define-data-var counter int 0)

;; Functions

(define (say-hi)
"hello world")

(define (increment-number (number int))
(+ 1 number))

(define (increment-number-by-10 (number int))
(+ 10 number))

(define (decrement-number (number int))
(- number 1))

(define (increment-counter)
(set-var! counter (+ 1 counter)))

(define (get-counter)
(counter))

 
To review other, longer sample programs visit the ]clarity-js-sdk[/url] repository.
 
 
  Collapse Read »

clarity smart contract language - cli command line

 
 
 
 
You use the clarity-cli command to work with smart contracts within the Blockstack virtual environment. This command has the following subcommands:
 
 
 


initialize
mine_block
get_block_height
check
launch
eval
eval_raw
repl
execute
generate_address


 
initialize
clarity-cli initialize [vm-state.db]
Initializes a local VM state database. If the database exists, this command throws an error.
 
mine_block
 
clarity-cli mine_block [block time] [vm-state.db]
Simulates mining a new block.

get_block_height
 
clarity-cli get_block_height [vm-state.db]

Prints the simulated block height.
 
 
 
check
 
clarity-cli check [program-file.scm] (vm-state.db)

Type checks a potential contract definition.

launch
 
clarity-cli launch [contract-name] [contract-definition.scm] [vm-state.db]
Launches a new contract in the local VM state database.
 
eval
 
clarity-cli eval [context-contract-name] (program.scm) [vm-state.db]
Evaluates, in read-only mode, a program in a given contract context.

eval_raw
 
Type check and evaluate an expression for validity inside of a function’s source. It does not evaluate within a contract or database context.

repl
 
 
clarity-cli repl
Type check and evaluate expressions in a stdin/stdout loop.

execute
 
clarity-cli execute [vm-state.db] [contract-name] [public-function-name] [sender-address] [args...]

Executes a public function of a defined contract.

generate_address
 
clarity-cli generate_address
Generates a random Stacks public address for testing purposes.
 
 
Continue Read »
 
 
 
 
You use the clarity-cli command to work with smart contracts within the Blockstack virtual environment. This command has the following subcommands:
 
 
 


initialize
mine_block
get_block_height
check
launch
eval
eval_raw
repl
execute
generate_address


 
initialize
clarity-cli initialize [vm-state.db]
Initializes a local VM state database. If the database exists, this command throws an error.
 
mine_block
 
clarity-cli mine_block [block time] [vm-state.db]
Simulates mining a new block.

get_block_height
 
clarity-cli get_block_height [vm-state.db]

Prints the simulated block height.
 
 
 
check
 
clarity-cli check [program-file.scm] (vm-state.db)

Type checks a potential contract definition.

launch
 
clarity-cli launch [contract-name] [contract-definition.scm] [vm-state.db]
Launches a new contract in the local VM state database.
 
eval
 
clarity-cli eval [context-contract-name] (program.scm) [vm-state.db]
Evaluates, in read-only mode, a program in a given contract context.

eval_raw
 
Type check and evaluate an expression for validity inside of a function’s source. It does not evaluate within a contract or database context.

repl
 
 
clarity-cli repl
Type check and evaluate expressions in a stdin/stdout loop.

execute
 
clarity-cli execute [vm-state.db] [contract-name] [public-function-name] [sender-address] [args...]

Executes a public function of a defined contract.

generate_address
 
clarity-cli generate_address
Generates a random Stacks public address for testing purposes.
 
  Collapse Read »

Hello Clarity tutorial

In this tutorial, you learn how to use Clarity, Blockstack’s smart contracting language. Use this tutorial to get a quick introduction to Clarity and the default Blockstack test environment.


Before you begin (pre-requisites)
Task 1: Set up the test environment
Task 2: Review a simple Clarity program
Task 3: Initialize data-space and launch contracts
Task 4. Examine the SQLite database
Task 5: Execute a public function
Task 6: Spend tokens by registering a name


 
Before you begin (pre-requisites)
 
The Clarity language goes live in the next Stacks blockchain fork. Until the fork, you can run Clarity in a test environment. You run this test environment in a Docker container. Before you begin this tutorial, make sure you have Docker installed on your workstation.

If for some reason you don’t want to run the test environment with Docker, you can build and maintain a local environment. Instructions for downloading and building the environment are available in the blockstack/blockstack-core repository’s README file.
 
Task 1: Set up the test environment
 
Blockstack publishes the clarity-developer-preview image on Docker hub. A container built from this image contains sample programs, the Blockstack Core, and tools for working with them. In this task, you use Docker to pull and and run the image on your local workstation.
 
 
1. Pull the Blockstack core clarity-developer-preview image from Docker Hub.
 
 $ docker pull blockstack/blockstack-core:clarity-developer-preview
2. Start the Blockstack Core test environment with a Bash shell.
$ docker run -it -v $HOME/blockstack-dev-data:/data/ blockstack/blockstack-core:clarity-developer-preview bash

 
The launches a container with the Clarity test environment and opens a bash shell into the container. The -v flag creates a local $HOME/blockstack-dev-data directory in your workstation and mounts it at the /data directory inside the container. The shell opens into the src/blockstack-core directory. This directory contains the source for a core and includes Clarity contract samples you can run.
 
 3. List the contents of the sample-programs directory.
 

root@f88368ba07b2:/src/blockstack-core# ls sample-programs/ names.clar tokens.clar
 
 
 
The sample programs directory contains two simple Clarity programs. Clarity code files have a .clar suffix.
 
 
 
4. Go ahead and display the contents of the tokens.clar program with the cat command.
root@c28600552694:/src/blockstack-core# cat sample-programs/tokens.clar
The next section gives you an introduction to the Clarity language by way of examining this program’s code.
 
 
Task 2: Review a simple Clarity program
 
If you haven’t already done so, use the cat or more command to display the tokens.clar file’s code. Clarity is designed for static analysis; it is not a compiled language and is not Turing complete. It language is a LISP-like language. LISP is an acronym for list processing.

The first line of the tokens.clar program contains a user-defined get-balance function.
 
 
 
(define (get-balance (account principal))
(default-to 0 (get balance (fetch-entry tokens (tuple (account account))))))

get-balance is a private function because it is constructed with the define call. To create public functions, you would use the define-public function. Public functions can be called from other contracts or even from the command line with the clarity-cli.

Notice the program is enclosed in () (parentheses) and each statement as well. The get-balance function takes an account argument of the special type principal. Principals represent a spending entity and are roughly equivalent to a Stacks address.

Along with the principal types, Clarity supports booleans, integers, and fixed length buffers. Variables are created via let binding but there is no support for mutating functions like set.

The next sequence of lines shows an if statement that allows you to set conditions for execution in the language..
 
 
(define (token-credit! (account principal) (tokens int))
(if (<= tokens 0)
(err "must move positive balance")
(let ((current-amount (get-balance account)))
(begin
(set-entry! tokens (tuple (account account))
(tuple (balance (+ tokens current-amount))))
(ok tokens)))))


 
Every smart contract has both a data space and code. The data space of a contract may only interact with that contract. This particular function is interacting with a map named tokens. The set-entry! function is a native function that sets the value associated with the input key to the inputted value in the tokens data map. Because set-entry! mutates data so it has an ! exclamation point; this is by convention in Clarity.

In the first token-transfer public function, you see that it calls the private get-balance function and passes it tx-sender. The tx-sender isa a globally defined variable that represents the the current principal.
 
(define-public (token-transfer (to principal) (amount int))
(let ((balance (get-balance tx-sender)))
(if (or (> amount balance) (<= amount 0))
(err "must transfer positive balance and possess funds")
(begin
(set-entry! tokens (tuple (account tx-sender))
(tuple (balance (- balance amount))))
(token-credit! to amount)))))

(define-public (mint! (amount int))
(let ((balance (get-balance tx-sender)))
(token-credit! tx-sender amount)))

(token-credit! 'SZ2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKQ9H6DPR 10000)
(token-credit! 'SM2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKQVX8X0G 300)


 
The final two lines of the program pass a principal, represented by a Stacks address, and an amount to the private user-defined token-credit function.

Smart contracts may call other smart contracts using a contract-call! function. This means that if a transaction invokes a function in a given smart contract, that function is able to make calls into other smart contracts on your behalf. The ability to read and do a static analysis of Clarity code allows clients to learn which functions a given smart contract will ever call. Good clients should always warn users about any potential side effects of a given transaction.

Take a moment to cat the contents of the names.clar file.
 
cat names.clar


 
Which tokens.clar function is being called?
 
Task 3: Initialize data-space and launch contracts
 
1. In this task, you interact with the the contracts using the clarity-cli command line.

Initialize a new db database in the /data/ directory
 
 #  clarity-cli initialize /data/db
Database created

You should see a message saying Database created. The command creates an SQLlite database. The database is available in the container and also in your workstation. In this tutorial, your workstation mount should at this point contain the $HOME/blockstack-dev-data/db directory.
 
2. Type check the names.clar contract.
 
 
 #  clarity-cli check sample-programs/names.clar /data/db

You should get an error:
Type check error. NoSuchContract("tokens")
This happens because the names.clar contract calls the tokens.clar contract, and that contract has not been created on the blockchain.

3.  Type check the tokens.clar contract, it should pass a check as it does not use the contract-call function:
 
 # clarity-cli check sample-programs/tokens.clar /data/db
Checks passed.
When the check command executes successfully and exits with the stand UNIX 0 exit code.
 
4. Launch the tokens.clar contract.
 
You use the launch command to instantiate a contract on the Stacks blockchain. If you have dependencies between contracts, for example names.clar is dependent on tokens.clar, you must launch the dependency first.
 
 # clarity-cli launch tokens sample-programs/tokens.clar /data/db
Contract initialized!

Once launched, you can execute the contract or a public method on the contract. Your development database has an instantiated tokens contract. If you were to close the container and restart it later with the same mount point and you wouldn’t need to relaunch that database; it persists until you remove it from your local drive.

5. Recheck the names.clar contract.
 # clarity-cli check sample-programs/names.clar /data/db

The program should pass validation because its dependency on tokens.clar is fulfilled.

6. Instantiate the names.clar contract as well.
 
# clarity-cli launch names sample-programs/names.clar /data/db
Task 4. Examine the SQLite database

The test environment uses a SQLite database to represent the blockchain. You initialized this database when you ran this earlier:
 
clarity-cli initialize /data/db
As you work the contracts, data is added to the db database because you pass this database as a parameter, for example:
 
clarity-cli launch tokens sample-programs/tokens.clar /data/db

The database exists on your local workstation and persists through restarts of the container. You can use this database to examine the effects of your Clarity programs. The tables in the SQLite database are the following:

 
 
 
While not required, you can install SQLite in your local environment and use it to examine the data associated with and impacted by your contract. For example, this what the maps_table contains after you initialize the tokens contract.
 
sqlite> select * from maps_table;
1|tokens|tokens|{"Atom":{"TupleType":{"type_map":{"account":{"Atom":"PrincipalType"}}}}}|{"Atom":{"TupleType":{"type_map":{"balance":{"Atom":"IntType"}}}}}
sqlite>

Task 5: Execute a public function
 
In this section, you use the public mint! function in the tokens contract to mint some new tokens.

1. Use the clarity_cli command to create a demo address.

# clarity-cli generate_address SP26CHZZ26Q25WDD1CFJYSED169PS9HTNX445XKDG

2. Add the address to your environment.

# DEMO_ADDRESS=SP26CHZZ26Q25WDD1CFJYSED169PS9HTNX445XKDG

3. Get the current balance of your new address.

# echo "(get-balance '$DEMO_ADDRESS)" | clarity-cli eval tokens /data/db Program executed successfully! Output: 0

This command uses the private get-balance function in the tokens contract and pipes the result to the eval subcommand. The eval subcommand lets you evaluate both public and private functions of a contract in read-only mode.

4. Try minting some tokens and sending them to an address we’ll use for our demo.

# clarity-cli execute /data/db tokens mint! $DEMO_ADDRESS 100000

This executes the public mint! function defined in the tokens contract, sending 100000 tokens to you $DEMO_ADDRESS.

5. Use the clarity-cli eval command to check the result of this call.

# echo "(get-balance '$DEMO_ADDRESS)" | clarity-cli eval tokens /data/db Program executed successfully! Output: 100000
 
 
Task 6: Spend tokens by registering a name
 
Now, let’s register a name using the names.clar contract. Names are just integers in this sample contract, so you’ll register the name 10.

Compute the hash of the name we want to register.

You’ll salt the hash with the salt 8888:
 
 # echo "(hash160 (xor 10 8888))" | clarity-cli eval names /data/db
Program executed successfully! Output:
0xb572fb1ce2e9665f1efd0994fe077b50c3a48fde

The value of the name hash is:
 
 0xb572fb1ce2e9665f1efd0994fe077b50c3a48fde
2. Preorder the name using the execute command:
# clarity-cli execute /data/db names preorder $DEMO_ADDRESS 0xb572fb1ce2e9665f1efd0994fe077b50c3a48fde 1000
Transaction executed and committed. Returned: 0
This executes the public preorder function defined in the names.clar contract. The function reserves a name by paying the name fee (in this case, 1000 tokens).

3. Check the demo address’ new balance:
# echo "(get-balance '$DEMO_ADDRESS)" | clarity-cli eval tokens /data/db
Program executed successfully! Output:
99000

4. Register the name by executing the register function:
 
# clarity-cli execute /data/db names register $DEMO_ADDRESS \'$DEMO_ADDRESS 10 8888
Transaction executed and committed. Returned: 0clarity-cli execute /data/db names register $DEMO_ADDRESS \'$DEMO_ADDRESS 10 8888

5. Lookup the “owner address” for the name:
 

# echo "(get owner (fetch-entry name-map (tuple (name 10))))" | clarity-cli eval names /data/db Program executed successfully! Output: (some 'SP26CHZZ26Q25WDD1CFJYSED169PS9HTNX445XKDG)
 
 
Continue Read »
In this tutorial, you learn how to use Clarity, Blockstack’s smart contracting language. Use this tutorial to get a quick introduction to Clarity and the default Blockstack test environment.


Before you begin (pre-requisites)
Task 1: Set up the test environment
Task 2: Review a simple Clarity program
Task 3: Initialize data-space and launch contracts
Task 4. Examine the SQLite database
Task 5: Execute a public function
Task 6: Spend tokens by registering a name


 
Before you begin (pre-requisites)
 
The Clarity language goes live in the next Stacks blockchain fork. Until the fork, you can run Clarity in a test environment. You run this test environment in a Docker container. Before you begin this tutorial, make sure you have Docker installed on your workstation.

If for some reason you don’t want to run the test environment with Docker, you can build and maintain a local environment. Instructions for downloading and building the environment are available in the blockstack/blockstack-core repository’s README file.
 
Task 1: Set up the test environment
 
Blockstack publishes the clarity-developer-preview image on Docker hub. A container built from this image contains sample programs, the Blockstack Core, and tools for working with them. In this task, you use Docker to pull and and run the image on your local workstation.
 
 
1. Pull the Blockstack core clarity-developer-preview image from Docker Hub.
 
 $ docker pull blockstack/blockstack-core:clarity-developer-preview
2. Start the Blockstack Core test environment with a Bash shell.
$ docker run -it -v $HOME/blockstack-dev-data:/data/ blockstack/blockstack-core:clarity-developer-preview bash

 
The launches a container with the Clarity test environment and opens a bash shell into the container. The -v flag creates a local $HOME/blockstack-dev-data directory in your workstation and mounts it at the /data directory inside the container. The shell opens into the src/blockstack-core directory. This directory contains the source for a core and includes Clarity contract samples you can run.
 
 3. List the contents of the sample-programs directory.
 

root@f88368ba07b2:/src/blockstack-core# ls sample-programs/ names.clar tokens.clar
 
 
 
The sample programs directory contains two simple Clarity programs. Clarity code files have a .clar suffix.
 
 
 
4. Go ahead and display the contents of the tokens.clar program with the cat command.
root@c28600552694:/src/blockstack-core# cat sample-programs/tokens.clar
The next section gives you an introduction to the Clarity language by way of examining this program’s code.
 
 
Task 2: Review a simple Clarity program
 
If you haven’t already done so, use the cat or more command to display the tokens.clar file’s code. Clarity is designed for static analysis; it is not a compiled language and is not Turing complete. It language is a LISP-like language. LISP is an acronym for list processing.

The first line of the tokens.clar program contains a user-defined get-balance function.
 
 
 
(define (get-balance (account principal))
(default-to 0 (get balance (fetch-entry tokens (tuple (account account))))))

get-balance is a private function because it is constructed with the define call. To create public functions, you would use the define-public function. Public functions can be called from other contracts or even from the command line with the clarity-cli.

Notice the program is enclosed in () (parentheses) and each statement as well. The get-balance function takes an account argument of the special type principal. Principals represent a spending entity and are roughly equivalent to a Stacks address.

Along with the principal types, Clarity supports booleans, integers, and fixed length buffers. Variables are created via let binding but there is no support for mutating functions like set.

The next sequence of lines shows an if statement that allows you to set conditions for execution in the language..
 
 
(define (token-credit! (account principal) (tokens int))
(if (<= tokens 0)
(err "must move positive balance")
(let ((current-amount (get-balance account)))
(begin
(set-entry! tokens (tuple (account account))
(tuple (balance (+ tokens current-amount))))
(ok tokens)))))


 
Every smart contract has both a data space and code. The data space of a contract may only interact with that contract. This particular function is interacting with a map named tokens. The set-entry! function is a native function that sets the value associated with the input key to the inputted value in the tokens data map. Because set-entry! mutates data so it has an ! exclamation point; this is by convention in Clarity.

In the first token-transfer public function, you see that it calls the private get-balance function and passes it tx-sender. The tx-sender isa a globally defined variable that represents the the current principal.
 
(define-public (token-transfer (to principal) (amount int))
(let ((balance (get-balance tx-sender)))
(if (or (> amount balance) (<= amount 0))
(err "must transfer positive balance and possess funds")
(begin
(set-entry! tokens (tuple (account tx-sender))
(tuple (balance (- balance amount))))
(token-credit! to amount)))))

(define-public (mint! (amount int))
(let ((balance (get-balance tx-sender)))
(token-credit! tx-sender amount)))

(token-credit! 'SZ2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKQ9H6DPR 10000)
(token-credit! 'SM2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKQVX8X0G 300)


 
The final two lines of the program pass a principal, represented by a Stacks address, and an amount to the private user-defined token-credit function.

Smart contracts may call other smart contracts using a contract-call! function. This means that if a transaction invokes a function in a given smart contract, that function is able to make calls into other smart contracts on your behalf. The ability to read and do a static analysis of Clarity code allows clients to learn which functions a given smart contract will ever call. Good clients should always warn users about any potential side effects of a given transaction.

Take a moment to cat the contents of the names.clar file.
 
cat names.clar


 
Which tokens.clar function is being called?
 
Task 3: Initialize data-space and launch contracts
 
1. In this task, you interact with the the contracts using the clarity-cli command line.

Initialize a new db database in the /data/ directory
 
 #  clarity-cli initialize /data/db
Database created

You should see a message saying Database created. The command creates an SQLlite database. The database is available in the container and also in your workstation. In this tutorial, your workstation mount should at this point contain the $HOME/blockstack-dev-data/db directory.
 
2. Type check the names.clar contract.
 
 
 #  clarity-cli check sample-programs/names.clar /data/db

You should get an error:
Type check error. NoSuchContract("tokens")
This happens because the names.clar contract calls the tokens.clar contract, and that contract has not been created on the blockchain.

3.  Type check the tokens.clar contract, it should pass a check as it does not use the contract-call function:
 
 # clarity-cli check sample-programs/tokens.clar /data/db
Checks passed.
When the check command executes successfully and exits with the stand UNIX 0 exit code.
 
4. Launch the tokens.clar contract.
 
You use the launch command to instantiate a contract on the Stacks blockchain. If you have dependencies between contracts, for example names.clar is dependent on tokens.clar, you must launch the dependency first.
 
 # clarity-cli launch tokens sample-programs/tokens.clar /data/db
Contract initialized!

Once launched, you can execute the contract or a public method on the contract. Your development database has an instantiated tokens contract. If you were to close the container and restart it later with the same mount point and you wouldn’t need to relaunch that database; it persists until you remove it from your local drive.

5. Recheck the names.clar contract.
 # clarity-cli check sample-programs/names.clar /data/db

The program should pass validation because its dependency on tokens.clar is fulfilled.

6. Instantiate the names.clar contract as well.
 
# clarity-cli launch names sample-programs/names.clar /data/db
Task 4. Examine the SQLite database

The test environment uses a SQLite database to represent the blockchain. You initialized this database when you ran this earlier:
 
clarity-cli initialize /data/db
As you work the contracts, data is added to the db database because you pass this database as a parameter, for example:
 
clarity-cli launch tokens sample-programs/tokens.clar /data/db

The database exists on your local workstation and persists through restarts of the container. You can use this database to examine the effects of your Clarity programs. The tables in the SQLite database are the following:

 
 
 
While not required, you can install SQLite in your local environment and use it to examine the data associated with and impacted by your contract. For example, this what the maps_table contains after you initialize the tokens contract.
 
sqlite> select * from maps_table;
1|tokens|tokens|{"Atom":{"TupleType":{"type_map":{"account":{"Atom":"PrincipalType"}}}}}|{"Atom":{"TupleType":{"type_map":{"balance":{"Atom":"IntType"}}}}}
sqlite>

Task 5: Execute a public function
 
In this section, you use the public mint! function in the tokens contract to mint some new tokens.

1. Use the clarity_cli command to create a demo address.

# clarity-cli generate_address SP26CHZZ26Q25WDD1CFJYSED169PS9HTNX445XKDG

2. Add the address to your environment.

# DEMO_ADDRESS=SP26CHZZ26Q25WDD1CFJYSED169PS9HTNX445XKDG

3. Get the current balance of your new address.

# echo "(get-balance '$DEMO_ADDRESS)" | clarity-cli eval tokens /data/db Program executed successfully! Output: 0

This command uses the private get-balance function in the tokens contract and pipes the result to the eval subcommand. The eval subcommand lets you evaluate both public and private functions of a contract in read-only mode.

4. Try minting some tokens and sending them to an address we’ll use for our demo.

# clarity-cli execute /data/db tokens mint! $DEMO_ADDRESS 100000

This executes the public mint! function defined in the tokens contract, sending 100000 tokens to you $DEMO_ADDRESS.

5. Use the clarity-cli eval command to check the result of this call.

# echo "(get-balance '$DEMO_ADDRESS)" | clarity-cli eval tokens /data/db Program executed successfully! Output: 100000
 
 
Task 6: Spend tokens by registering a name
 
Now, let’s register a name using the names.clar contract. Names are just integers in this sample contract, so you’ll register the name 10.

Compute the hash of the name we want to register.

You’ll salt the hash with the salt 8888:
 
 # echo "(hash160 (xor 10 8888))" | clarity-cli eval names /data/db
Program executed successfully! Output:
0xb572fb1ce2e9665f1efd0994fe077b50c3a48fde

The value of the name hash is:
 
 0xb572fb1ce2e9665f1efd0994fe077b50c3a48fde
2. Preorder the name using the execute command:
# clarity-cli execute /data/db names preorder $DEMO_ADDRESS 0xb572fb1ce2e9665f1efd0994fe077b50c3a48fde 1000
Transaction executed and committed. Returned: 0
This executes the public preorder function defined in the names.clar contract. The function reserves a name by paying the name fee (in this case, 1000 tokens).

3. Check the demo address’ new balance:
# echo "(get-balance '$DEMO_ADDRESS)" | clarity-cli eval tokens /data/db
Program executed successfully! Output:
99000

4. Register the name by executing the register function:
 
# clarity-cli execute /data/db names register $DEMO_ADDRESS \'$DEMO_ADDRESS 10 8888
Transaction executed and committed. Returned: 0clarity-cli execute /data/db names register $DEMO_ADDRESS \'$DEMO_ADDRESS 10 8888

5. Lookup the “owner address” for the name:
 

# echo "(get owner (fetch-entry name-map (tuple (name 10))))" | clarity-cli eval names /data/db Program executed successfully! Output: (some 'SP26CHZZ26Q25WDD1CFJYSED169PS9HTNX445XKDG)
 
  Collapse Read »