Guide to avoid scam with crypto

Keep self-custody of your crypto asset

For Noncustodial wallets keep your recovery code safe

Don’t fall in trap if wallet application asks for recovery code for no reasonRecovery code is asked while creating a wallet i.e. initial setup or if you have lost your wallet i.e. recovery – other than that ensure that you are been not phished

Don’t keep all you crypto assets in a single address

Don’t share the same address to multiple person – Private keys are used to generate the Bitcoin Address. For each transaction create a new address. This way you avoid anybody to know how much bitcoin has been sent to that address in total. Generating new address everytime also protects your privacy.

Block explorer privacy – Block explorer is a web appplication that operates as a Bitcoin search engine. You can search by Bitcoin addresse, transaction hash, block number and block hash. Using these applications and searching a transaction allows them to associate the IP address, previous earches and browser details through which can identify and learn your activities. Searching somebody else transaction should not be a problem but if you search your own transactions these operators might be able to analyse the Bitcoin your have received and spent or currently own. So as mentioned earleir each transaction should be on different address to make the operators difficult to identify you.

Ways to acquire a Bitcoin as a new user

Bitcoin transactions are irreversible. So be careful when doing transaction either send or receive. Since the transactions are done on address and there is not identity attached, there is no verification process to check if the address is your’s before doing a transaction. This way acquring, holding and spending bitcoin does not expose your personal identity. Although everybody in the network can see the how much bitcoin is in a address but that address doesn’t disclose your identity. As a new user follow this guidelines-

  • First do a self study how the crypto transaction works. With most of the mobile apps its as as easy as transfering the fiat currency. But if you have a self custodial assets its very important to understand the process. Understand the current Price of bitcoin from the currency exchange, transaction fees, location from where you will be doing transactions. It is good to understand the rules and regulations of the country where you reside.
  • Get introduction about bitcoin from a friend – Take help from you friend who already has Bitcoin and buy from your them directly with a small amount. This should give you a confidence when doing further transactions by yourself. Once you are familiarised and have confidently done transactions help new users and share your expereince.
  • Earn a bitcoin. Earn a bitcoin by providing service with which ever profession you are in. Example- if you are porgrammer you sell your skills for firat currency, instead sell your service for bitcoin. This requires to share your adddress along with the invoice to your client who should then send agreed bitcoin to your address. This way you learn how to generate address to receive bitcoin. Always remember to genereate new address for each invoice. See section “Don’t share the same address to multiple person“.
  • Use Bitcoin ATM – A Bitcoin ATM is a standalone device or kiosk that allows you to buy or sell bitcoin or other cryptocurrencies using a terminal. Bitcoin ATMs are connected to the Internet and often utilize QR codes to send and receive tokens to users’ digital wallets. Bitcoin ATM accepts cash and send bitcoins to your wallet. This way you get to familiarise with bitcoin transaction’s.
  • Use Bitcoin currency eschange – you can buy bitcoin from the digital curerncy exchange such as Coinbase which is linked to your back account. Although they will take the transaction fees but a safe way to buy or sell the bitcoins.

Loading

How to set background image using Next js in Sitecore XM Cloud

This is a very common scenario where a background image needs to be set to certain components. Banner’s on any page on your website is a very common place to have a background image.

This blog assumes you have setup the Foundation Head setup or have your own Nextjs project setup implemented using the Sitecore NextJS SDK.

Note: This is not specific to XM Cloud but for any Headless implementation

Foundation Head already has an example on setting the background image using params. In this blog post will explore how this works and where in Sitecore the image can be applied. Will see how this can applied using using OOTB _Background Image item.

To apply image background using rendering parameters to the container see this blog here

Applying background image using rendering field to the components

Background image can be applied to components inheriting the existing __Background Image item to the custom component template.

Create a template for your component. Here I am creating a Banner component-

Inherit _Background Image from /sitecore/templates/Foundation/Experience Accelerator/Presentation/_Background Image

_Background Image has “Background Image” and “Stretch mode” field.

Note that there is a space between the field names, although not recommended but this comes OOTB.

Create a “Banner” JSON Rendering and provide the “Parameters Template”, “Datasource Location” and “Datasource Template” as per your requirement and add this rendering to the “Available Renderings”

Create a Nextjs component in sxastarter project

Note below how the “Background Image” field is set. This is due to the same in field name. Not recommended but this is OOTB.

View this gist on GitHub

Experience Editor-

Add a container component in Main placeholder-

Add a newly created component (Banner) in Container placeholder-

Create or select associated content

Once the component is added you should see the button to Add Background Image ( ths is added when the template inherits from _Background Image template.

Select the Background Image and Save-

You should now able to see the background image to component-

Rendering Host-

Reference-

https://doc.sitecore.com/xmc/en/users/xm-cloud/add-a-background-image.html

First Rust project using cargo package manager

If this is the first time you are using Rust you will have to install Rust on your Windows machine.

To install see this link – https://www.rust-lang.org/tools/install

Check the version of Rust-

rustup --version

Check the version of Rsut compiler

rustc --version

Create a Rust project using Cargo

Cargo is a build and package manager.

For creating a new Rust project using Cargo package manager-

cargo new first_rust_prj

This should create follwoing folder structure with main.rs and Cargo.toml (configuration) file.

You can create a project without using Cargo. Create a src directory and create appropriate Cargo.toml namually. To create toml file use init command

cardo init

Building and Running Cargo project

Build the Cargo project using following command-

cargo build

To compile and run directly from the project folder, use following command-

cargo run

Error compiling the project-

error: linker link.exe not found

So the pre-requisite for windows machine is to have MS C++ build tools. Install the smae from here. It should be around 5 GB.

https://visualstudio.microsoft.com/visual-cpp-build-tools

Now this should run the project –

To check the code without producing an executable use follwoing command-

cargo check

Building for Release

Use following command when project is ready for release-

cargo build --release

References-

https://doc.rust-lang.org/book/ch01-01-installation.html#installing-rustup-on-linux-or-macos

Loading

All about Rust Cargo commands

Cargo is Rust’s build system and package manager. Most developers use this tool to manage their Rust projects because Cargo handles a lot of tasks for you, such as building your code, downloading the libraries your code depends on, and building those libraries.

Cargo commands and its usage-

Check the cargo version

cargo --version

Create a new project

Create a new project using Cargo.

cargo new <<project_name>>

Build the Cargo project

Build command compiles the project and create’s an executable file in /debug/ folder. Running the cargo build command updated the Cargo.lock file which keeps the trakc of exact version of dependecies in the project.

cargo build

Running a Cargo project

Cargo run compiles the project and runs the resultant executable all in one command. So instead of remembering the cargo build and path to execute the excutable, Cargo run does both for you which is more conveninent

cargo run

Check your code

If you want to quickly check if the code to make sure it complies susccesfully without using build or run command, you can use check command. This nmusch faster than build because it skips the step to create an executable.

cargo check

Update the project dependencies

Update the dependeincies of you project using update command. This ignores the Cargo.lock file which has all the dependencies. update command will look for one higher version than current version e..g: if the current version is 0.7.5 and the latest version is 0.8.0. But if there is next higher version i.e. 0.7.6, then update command will udpate the dependency to 0.7.6. Also after update the Cargo.lock file is udpated.

If you want to jump to a specific version, as per above case to 0.8.0. Update hte Cargo.toml file dependencies section.

cargo update

This is WIP, there is lot more to add here.

Loading

Bitcoin Notes

Bitcoin is a internet of money. Invented in 2008. Started in 2009

Bitcoin consists of –

  • Bitcoin Protocol – A denetralized peer-to-peer network
  • Blockchain – Public transaction ledger
  • Consensus rule – Set of rules for independent transaction validation and currency issuance
  • Proof-of-Work – Distributed computation system.

Mining– A decentralized mathematical and deterministic currency issuance. Competing to find solutions to a mathematical problem while processing bitcoin transactions (power to verify and record transactions) which is done every 10 minutes. Transactions become a part of blockchain and is included in a block by a miner, that process is called as mining

The mining process serves two purposes
in bitcoin:

  • Mining nodes validate all transactions by reference to bitcoin’s consensus rules.
    Therefore, mining provides security for bitcoin transactions by rejecting invalid
    or malformed transactions.
  • Mining creates new bitcoin in each block, almost like a central bank printing new
    money. The amount of bitcoin created per block is limited and diminishes with
    time, following a fixed issuance schedule

Mining uses electricity hsnece they has to be rewarded with a new bitcoin and any transaction fees. These provides security for Bitcoin without any central authority. Mining is a decentralized lottery system. Each miner create their own lottery ticket by creating a candidate block whihc includes new transactions which they want to mine. Do you know miner has to try 168 billion trillion candidate blocks before finding the winning combination.

Once the winning combination is found which takes a incredible work but other peers take trival amount of work to verify to prove the work was done, the winning block is the proof the work was done and is called as proof-of-work.

Transaction script – A decentralized transaction verification system.

Paper title – “Bitcoin: A Peer-to-Peer Electronic Cash System” written by Satoshi Nakamoto.

Fast, Secure and Borderless. Distributed, peer-to-peer system. No central server or point of control. Created through a process called as mining.

Bitcoin is completely decentralised by design and free of any central authority or point of control that can be attacked or corrupted.

Every 10 minutes or so, Mining computers compete against thousands of similar systems in a global race to find a solution to a block of transactions. Finding such a solution, the so called Proof-of-Work (PoW)

Fixed total 21 millions coins will be created by the year 2140.

Bitcoin is virtual. User of bitcoin own keys that allow then to prove ownership stored in digital wallet.

Block #0 is known as genesis block.

Application Specific Integrated Circuits (ASIC)

Unverified transactions when included in a new block it is called as candidate block.

Bitcoin Improvement Proposal

Important Notes-

  • Bitcoin currency will defalte in long term as the rate of issuance will reduce and ultimately diminish.
  • Bitcoin is not a physical or digital coins. The coins are implied in transactions that can be transfered from sender to receipient.
  • Bitcoin users can transfer funds using the keys that a re stored in digital wallet/ledger. They need to sign a tranasction to unlock the value and spend it by transfering the funds. key that can sign the transactions is the only pre-requisite to spend bitcoin.

Types of wallets-

  • Desktop Wallet
  • Mobile Wallet
  • Web Wallet
  • Hardware signing devices (Harware wallet – most secure)

Full node versus lightweight

  • Full node – offers complete autonomy to its users (self governance)
  • Lightweight client. simplified-payment-verification (SPV)
  • Third-party API client

Nodes

Peers in the Bitcoin peer-to-peer network are programs that have both software logic and necessary data that fully verify the correctness of new transactions. The connection between peers are visualized as edges(lines) in a graph with the peers themselves being the node (dots) Bitcoin peers are commonly called “full verification nodes” or full nodes for short.

What is gossiping

Any Bitcoin node that receives a valid transaction it has not seen before will forward it to all other nodes (peers) to which it is connected. This propagation technique is know as gossiping.

Abbrevations –

  • SPV – Simplified Payment Verification
  • NFC – Near field communication
  • POW – Proof of work
  • P2P – peer-to-peer network

Computing problems –

  • Byzantine Generals problem – consensus between various parties without a leader in distributed computing

Alogrithms-

  • proof-of-work algorithm (pow)

Setup BTCPay server in Azure

BTCPay Server is a self-hosted, open-source cryptocurrency payment processor. It’s secure, private, censorship-resistant and free.

Refer this link

Create a Resource group in Azure. I create this in West Us region.

Choose the template from the provided link and should take straight to your Azure subscription-

Enter the valid Vm Size and the supported crypto payment.

Select the Network – Mainnet, TestNet or regtest

Select the Ubuntu version. You may select the latest

Resources in Azure

This should create following resources in Azure in the selected resource group-

Navigate to BTCPayServerPublicIP resource. This should show the dns name.

This is your BTC pay admin portal.

Register Admin user

First time when you access the Btc Pay server should ask you to register a user. This user will be a owner.

Login to BTC pay server

Login with the newly created user

You will be asked to configure the lightining network and create a wallet.

Configuring the wallet and lightning network will follow in next blog along with integration with integration with commerce system such as Order Cloud.

Stay tuned to know how to configure this which should ulitmately sync the nodes as shown in below screen.

Loading

Indexing Bitcoin Transaction Database

By default Bitcoin Core builds a database containing only the transactions for the user’s wallet.

Wallet transactions can be retireved using JSON RPC API gettransaction command.

But if you want to retrieve any transaction within the node use command getrawtransaction. This command will search transactions in the index.

bitcoin.conf file set txindex

Bitcoin daemon or GUI uses conf file to load settings. On the first bitcoind run it will ask to create a config file.

Set txindex=1 in the config file before running the daemon. If the indexing is enabled the bitcoin daemon then should start synching the blocks and index.

bitcond -reindex option

If the txindex is not set in config before the first run and if later you want to index the database use -reindex option.

Re-index should take a while. To improve perfromance disable -printtoconsole option

bitcoind -reindex -rpcuser=xxxx -rpcpassword=xxxxx

bitcond -txindex option

If the txindex is not set in config before the first run and if later you want to index the database use -txindex option.

bitcoind -txindex -rpcuser=xxxx -rpcpassword=xxxxx

XM CLoud Dev – How to set background image using rendering parameters

This is a very common scenario where a background image needs to be set to certain components. Banner’s on any page on your website is a very common place to have a background image.

Note: This is not specific to XM Cloud but for any Headless implementation

Foundation Head already has an example on setting the background image using params. In this blog post will explore how this works and where in Sitecore the image can be applied. Will see how this can applied using Rendering Parameters and using OOTB _Background Image item.

Applying background image using rendering parameters

Background image can be applied to container. If you are using Foundation Head repo you can find this component OOTB.

Thre Container rendering is at following lcoation in Sitecore –

/sitecore/layout/Renderings/Feature/JSS Experience Accelerator/Page Structure/Container

Note Other properties- IsRenderingsWithDynamicPlaceholders and IsRenderingsWithDynamicPlaceholders is set to true

Rendering parameter is located – /sitecore/templates/Feature/JSS Experience Accelerator/Page Structure/Rendering Parameters/Container

Rendering paramter template has the BackgroundImage field. The background image will be set based on the image selected in this field.

How the image is set in Head

Lets see background image set in nextjs (sxastarter) Container.tsx

// image string from the rendering parameters
 let backgroundImage = props.params.BackgroundImage as string;
  let backgroundStyle: { [key: string]: string } = {};
  console.log('backgroundImage1');
  console.log(backgroundImage);
  if (backgroundImage) {
    const prefix = `${sitecoreContext.pageState !== 'normal' ? '/sitecore/shell' : ''}/-/media/`;
    backgroundImage = `${backgroundImage?.match(BACKGROUND_REG_EXP)?.pop()?.replace(/-/gi, '')}`;
    backgroundStyle = {
      backgroundImage: `url('${prefix}${backgroundImage}')`,
    };
  }

  return (
    <div className={`component container-default ${styles}`} id={id ? id : undefined}>

// style applied to <div> having background image
      <div className="component-content" style={backgroundStyle}>
        <div className="row">
          <Placeholder name={phKey} rendering={props.rendering} />
        </div>
      </div>
    </div>
  );
};

Lets see this in working in experience editor and rendering host

In the experience editor main section add a container component.

Once the rendering is added, goto “Edit component properties” and add an background image

Now you are able to see the background image applied ot container and I have added RichText in containerto show the image in background-

Rendering Host displays the image in background-

Nested containers to apply differnt background image or component

If you add only one container the image will be applied to the main section.

To resolve this you can add a container within main container. add mutiple containers as per your requirements. To set the background image to specific container in this example contianer-2 select the parent(i.e. container) and set the image by Editing the Component properties

This should apply the different images for various other sections in the sampe page and since the Container rendering has IsRenderingsWithDynamicPlaceholders property set this should create a unique Id for each container.

Here for example container-2 and container-3 is a child of container-1

Rendering Host displays banckgroung images with there respective components-

Isusue- Here you can see there is a white patch when applied to child container and the image is applied to inner div.

To resolev this apply the image to the outer div instead in container.tsx

return (
    <div className={`component container-default ${styles}`} style={backgroundStyle} id={id ? id : undefined}> // backgroundStyle added
      <div className="component-content"> // backgroundStyle removed
        <div className="row">
          <Placeholder name={phKey} rendering={props.rendering} />
        </div>
      </div>
    </div>
  );

Here you can seee a full width background image

Hope these tips helps.

Deploy Headless SXA Site to XM Cloud

In this blog blost lets create Project and Environment to deploy the sxastarter site to XM Cloud. The deployment is based on the existing repository in GitHub and have solution ready to deploy. Please see this blog posts on how to fork Foundation Head Template and setup your local instance along with creating Headless SXA Site(sxastarter) also configure the serliazation of Sitecore items.

To create project and environment you need to have access to XM Cloud either Admin or Contributor.

Login to XM Cloud

https://portal.sitecorecloud.io/

XM Cloud Organization-

Contains organization you are assigned to-

An organization is business unit either company or brand and contains team members and Sitecore Products you are subscribed and can have more than one Sitecore Product as seen in the below screen.

XM Cloud Deploy

As highlighted quick links container XM Cloud Deploy

https://deploy.sitecorecloud.io/

Deploy contanis list of projects and deployments done for each project and environments. It also container connections to GitHub or Vercel if site is hosted their.

The highlighted shows Organization name at the top and list of projects.

Connect to GitHub (Source Control Connections)

Ensure the changes (Sitecore Items) are pushed to GitHub repo.

Recommended – create separate branch for each environment. I have created dev, staging and main(prod)

Connections – should show list of all connections for projects mainly Github and Azure Devop for Source Control, while hosting connections can be mafe to Vercel. In this section we will configure GitHub provider.

Create a new GitHub connection

Should ask to login and provide access to a repository, you may choose all or specific repository-

Since I already had connection you will be shown a different option to Install and Authorize

Create Project

Click on Create project option

This should show the type of project to be created. We want to start from our own Source Code(GitHub) based on the connection made.

Since we configured only GitHub connection defaults to this Source Control-

Your connection name will be displayed here. Choose the connection. This will also show any other connections available.

You may also create a new connection from here.

Provide the project name and the repository where Foundation Head code resides along with any other changes you might have done sa a part of development.

Environment name – provide name – should be able to relate which branch is this pulled from.

Production environment – if this is then choose yes, I have selected this as no since I ma setting dev environment

Linked branch- Select the appropriate branch ensure yuo have all the changes available in this branch which you want to deploy

Trigger deployment on commit to branch – Set if this has to be auto deployed if changes are pushed to selected branch.

Deploy. This should start the deployment. This should take 10 -15 mins. Wait for the post actions.

You should now see the newly created project with dev environment-

New Project Created

New Environment Created

New Site Created (sxastarter)

Select environment and goto Sites tab-

Will see in the next blog hot to setup the Hosting

Select environment and Details tab- You should be able to see hostname, url’s and tokens along with Environment details.

Click on the Dashboard link –> Tools to see if the items are synched-

We now have templates, content and relevant items in layouts and image created

Content Editor with Site Collection, Site and Content

Templates Created

Experience Editor

Lets check the home page in experience editor

In the next bog will configure the Site hosting to Vercel.

Errors-

In connections select Create Connection –> GitHub

Click on Uninstall “Sitecore Deploy Prod”

Follow the process of creating a Connection again and this time you will see option to Install & Authorize

Once this is done an confirmed try creating a project –

Loading

Sitecore CDP- Create Guests using REST Api

https://{apiEndpoint}/v2/guests

Request to the api-

Use Client Key in User name and API Token in password to send request with Basic Auth-

Response-

Note ref field. The ref field is a guest reference which can be used further to extend or pull the guests details-

See the Properties tab to verify all the guests details-

cURL code snippet-

curl --location --request POST 'https://api.boxever.com/v2/guests' \
--header 'Authorization: Basic <<Enter Token>>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "guestType": "customer",
    "title": "Mr",
    "firstName": "Icy",
    "lastName": "Saber",
    "gender": "male",
    "dateOfBirth": "",
    "emails": [
        "icy.saber@mailfy.com"
    ],
    "phoneNumbers": [
        "01234567890"
    ],
    "nationality": "British",
    "passportNumber": "GB4B9565",
    "passportExpiry": "",
    "street": [
        "Apartment 140",
        "West Drive Avenue"
    ],
    "city": "London",
    "country": "GB",
    "postCode": "SW12",
    "state": "London"
}

C# code snippet-

var client = new RestClient("https://api.boxever.com/v2/guests");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Basic <<Enter Token>>");
request.AddHeader("Content-Type", "application/json");
var body = @"{
" + "\n" +
@"    ""guestType"": ""customer"",
" + "\n" +
@"    ""title"": ""Mr"",
" + "\n" +
@"    ""firstName"": ""Icy"",
" + "\n" +
@"    ""lastName"": ""Saber"",
" + "\n" +
@"    ""gender"": ""male"",
" + "\n" +
@"    ""dateOfBirth"": """",
" + "\n" +
@"    ""emails"": [
" + "\n" +
@"        ""icy.saber@mailfy.com""
" + "\n" +
@"    ],
" + "\n" +
@"    ""phoneNumbers"": [
" + "\n" +
@"        ""01234567890""
" + "\n" +
@"    ],
" + "\n" +
@"    ""nationality"": ""British"",
" + "\n" +
@"    ""passportNumber"": ""GB4B9565"",
" + "\n" +
@"    ""passportExpiry"": """",
" + "\n" +
@"    ""street"": [
" + "\n" +
@"        ""Apartment 140"",
" + "\n" +
@"        ""West Drive Avenue""
" + "\n" +
@"    ],
" + "\n" +
@"    ""city"": ""London"",
" + "\n" +
@"    ""country"": ""GB"",
" + "\n" +
@"    ""postCode"": ""SW12"",
" + "\n" +
@"    ""state"": ""London""
" + "\n" +
@"}
" + "\n" +
@"
" + "\n" +
@"";
request.AddParameter("application/json", body,  ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);

Python code snippet-

import http.client
import json

conn = http.client.HTTPSConnection("api.boxever.com")
payload = json.dumps({
  "guestType": "customer",
  "title": "Mr",
  "firstName": "Icy",
  "lastName": "Saber",
  "gender": "male",
  "dateOfBirth": "",
  "emails": [
    "icy.saber@mailfy.com"
  ],
  "phoneNumbers": [
    "01234567890"
  ],
  "nationality": "British",
  "passportNumber": "GB4B9565",
  "passportExpiry": "",
  "street": [
    "Apartment 140",
    "West Drive Avenue"
  ],
  "city": "London",
  "country": "GB",
  "postCode": "SW12",
  "state": "London"
})
headers = {
  'Authorization': 'Basic <Enter Token>>',
  'Content-Type': 'application/json'
}
conn.request("POST", "/v2/guests", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

Reference-

https://doc.sitecore.com/cdp/en/developers/sitecore-customer-data-platform–data-model-2-1/use-the-create-guest-function-in-sitecore-cdp-rest-api.html

https://doc.sitecore.com/cdp/en/developers/sitecore-customer-data-platform–data-model-2-1/overview-of-sitecore-cdp-rest-apis.html

https://doc.sitecore.com/cdp/en/developers/sitecore-customer-data-platform–data-model-2-1/sitecore-cdp-guest-extensions-data-model-for-rest-api.html

Loading