teleren/devto huggingface dataset:
How to deploy a smart contract to the same address across different blockchains?
Tags: blockchain, solidity, smartcontract, ethereum
Published: 2022-04-04 03:04:00

Have you ever deployed a smart contract and noticed the deployed address? It seems to be a bunch of random characters, and while it is, that address is deterministic.

**A quick primer on account and address in Ethereum** - There are two types of accounts in Ethereum: Externally Owned Account (EOA) and Contract Account. Both types of accounts have an address associated with them. An address in Ethereum is a 42-character hexadecimal address.

E.g., [Uniswap's](https://docs.uniswap.org/protocol/reference/deployments) UniswapV3Factory smart contract address is *0x1F98431c8aD98523631AE4a59f267346ea31F984* and is the same in Ethereum mainnet, Polygon, Optimism, Arbitrum, and Avalanche. The same is the case for Uniswap's all smart contracts.


**How is the smart contract address generated?**
The smart contract's address is derived from two values, the EOA user's address and the number of transactions the user has sent. That is the user's wallet address and nonce.

**Primer on Nonce** - Nonce, simply put, is the number of transactions a user has done in a given blockchain. Every time a user has an outgoing transaction, the nonce increases by one. The nonce is unique for each blockchain, meaning that sending a transaction in Ethereum will increase the account's nonce in Ethereum but not in Polygon.

>Please note that we refer to the account nonce, which pertains to the user, and not to the block nonce.

As I mentioned at the start of the article, the smart contract address is deterministic. We can determine the address before the smart contract is actually deployed using the wallet's address from which the user will deploy the contract and their most recent nonce + 1. 

Below is the example code using ether.js to compute the address pre-deployment. [Verify](https://mumbai.polygonscan.com/tx/0x84760a4617c32d2acd90c2c9baf465abbb72a64e26420585a0eca299eea9efef
) the output

{% gist https://gist.github.com/prashantnigam10/f42bcf27531a8a8b49066819bd382da3 %}

Finally, to answer the question, "How to deploy a smart contract to the same address across blockchains?"

In our wallet, I use Metamask, we should keep an account, and let's call it the deployment account, only to deploy the smart contracts. We should not do any transactions in it other than smart contract creation. Sending smart contract creation transactions in all the blockchains with the same nonce will result in the same smart contract address everywhere.

Having the same address makes the smart contract much more developer-friendly. It reduces the friction of maintaining addresses for different env (mainnet vs. testnet) and blockchains (Ethereum, Polygon, etc.). It makes it easier to socialize the launch as well.


I hope you found this useful! If you have any questions or feedback, please let me know in the comments, and I will be happy to answer.
How to Integrate Razorpay Payment Gateway in Laravel
Tags: laravel, php, paymentgateway, razorpay
Published: 2022-04-04 03:03:31

In this tutorial, We will see how to integrate razorpay payment gateway in laravel. Razorpay is the only payments solution in India that allows businesses to accept, process and disburse payments with its product suite. Razorpay payment gateway accepts all payment modes with domestic and international credit & debit cards, EMIs ( Credit/Debit Cards & Cardless), PayLater, Netbanking from 58 banks, UPI and 8 mobile wallets, Razorpay provides the most extensive set of payment methods.

Razorpay payment gateway integration is very easy to use like another payment gateway. In laravel 8 we can demonstrate razorpay payment gateway integration. Read more Developer Docs of razorpay payment gateway.

So, let's see razorpay payment gateway integration in laravel 7 and laravel 8, how to integrate razorpay payment gateway in laravel 8, razorpay payment gateway integration in laravel 7

```
Step 1 : Create Razorpay Account in Razorpay

Step 2 : Install Razorpay Package

Step 3 : Add API Key and Secret Key

Step 4 : Create Route

Step 5 : Create Controller

Step 6 : Create View File
```

---

**_[Read More : How to Integrate Razorpay Payment Gateway in Laravel](https://techsolutionstuff.com/post/how-to-integrate-razorpay-payment-gateway-in-laravel)_**
Getting Nginx to work
Published: 2022-04-04 02:29:36

This past week I finally finished the work necessary for the [issue](https://github.com/Seneca-CDOT/telescope/issues/2993) about sharing a single nginx container for all static sites.

I moved `docusaurus` and `test-web-content` into `src/web` in [separate](https://github.com/Seneca-CDOT/telescope/pull/3349) [PRs](https://github.com/Seneca-CDOT/telescope/pull/3360) and then started working on the Nginx config and Dockerfile.

I originally posted a [PR](https://github.com/Seneca-CDOT/telescope/pull/3367) with an Nginx config that would put the Telescope app and the Docusaurus app in two different ports but I was told in the review process to keep everything on port 8000 and simply have Docusaurus at `/docs` which makes a lot more sense.

I was stuck for a while on getting the Docusaurus app to show on `localhost:8000/docs` as I kept getting a 403 Error message. Eventually, with help from [Josue](https://github.com/manekenpix), I managed to make the configuration work.

## Dockefile

The [Dockerfile](https://github.com/Seneca-CDOT/telescope/blob/3db970d106d8d9aaffb539d8b45f98c34ddd58ba/src/web/Dockerfile) is divided into different layers. It starts with `node:16` as base and then goes through separate layers to install dependencies and build the apps. Each layer is specific to either the Telescope app or the Docusaurus app so that if there's a change in one, not everything needs to be rebuilt from scratch.

The final layer uses the Nginx Alpine image (Alpine images are famous for being much smaller in size) and inside we copy the builds from previous layers like this:

```docker
FROM nginx:1.20.2-alpine as deploy

WORKDIR /

COPY --from=build-app /app/out /var/www/data

COPY --from=build-docs /docs/build /usr/share/nginx/html/docs
```

## Nginx config

For Nginx, I had to add following to the [config template](https://github.com/Seneca-CDOT/telescope/blob/3db970d106d8d9aaffb539d8b45f98c34ddd58ba/config/nginx.conf.development.template#L154):

```console
location /docs {
	root /usr/share/nginx/html;
}
```

and change the baseUrl in `docusaurus.config.js` to `/docs/`.

It definitely took longer than I expected to get all of this working since I am still new to Docker but it was very rewarding to see it work. Hopefully this PR can be merged soon.

---

Finally, since we are getting close to release the Docusaurus app to production, I also took the opportunity to fix all the broken links with this [PR](https://github.com/Seneca-CDOT/telescope/pull/3376).
Release 2.9
Tags: opensource
Published: 2022-04-04 02:23:51

## My Work

[Apply Dockerfile best practices from Snyk recommendations #1668](https://github.com/Seneca-CDOT/telescope/issues/1668) 
List of Dockerfile worked:
- https://github.com/Seneca-CDOT/telescope/pull/3231
- https://github.com/Seneca-CDOT/telescope/pull/3256
- https://github.com/Seneca-CDOT/telescope/pull/3236
- https://github.com/Seneca-CDOT/telescope/pull/3235
- https://github.com/Seneca-CDOT/telescope/pull/3255
- https://github.com/Seneca-CDOT/telescope/pull/3238
- https://github.com/Seneca-CDOT/telescope/pull/3307 (In progress, fixing failing e2e test)
- https://github.com/Seneca-CDOT/telescope/pull/3239
- https://github.com/Seneca-CDOT/telescope/pull/3309

In overall it was pretty straightforward once one of the PR got reviewed, and I can use it as a template.

## One of the process steps
References
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kl294lauud2o7i2cqjd6.png)
{% embed https://www.youtube.com/watch?v=8vXoMqWgbQQ %}

- For the image version we need to use an image to a specific version(Not using alpine version for package installation since M1 required more tools to work)
```yml
 - FROM node:lts as base
 + FROM node:16 as base
```

- Setup multi staging
```yml
 + FROM node:16 as base
 + FROM base as dependencies
 + FROM node:16-alpine3.15 as deploy
```
Base stage is for installing the tool needed for package installation. 
Dependencies stage is for installing node_modules.
Deploy stage is where we copy sources code from the build context and node_modules from Dependencies and run our services.

- Run node app as node user
```yml
+ COPY --chown=node:node . .
+ USER node
```
This allows Node user to have permission to read our sources code.

- Add a healthcheck
```yml
+ ENV PORT
+ HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
+	CMD wget --no-verbose --tries=1 --spider localhost:${DEPENDENCY_DISCOVERY_PORT}/healthcheck || exit 1
```
This is the change I made, one thing [@humphd](https://github.com/humphd) noticed building the application with a node-alpine image, on ARM architecture, it's required to use a bigger node image to be able to build it. [See PR 3336] (https://github.com/Seneca-CDOT/telescope/pull/3336)
FIDO Developer Tutorial Tool
Tags: javascript, tutorial, git, cybersecurity
Published: 2022-03-31 17:46:56

Developer Tutorial Tool designed to help website and app developers gain a better understanding of how FIDO2 flows work. The tool leverages Java Script Web SDK and backend APIs to provide a good starting point.

Via this demo, developers can see how the following features will work for them if they integrate the SDKs into their website or app:

- Register and Authenticate Users with FIDO2 Passwordless Authentication
- Add Credentials to an Existing User Account
- Enable Temporary or One-Time Access to an Account
- Generate a Transaction Confirmation by Using a Digital Biometric Signature
- Take Advantage of Kong Gateway Plugin

## Get Started
Click [HERE](https://github.com/loginid1/loginid-tutorial) to view the easy to follow tutorial on Github and get started with a sample integration. The below image provides a view of what the tutorial setup will look like.


![Example of LoginID Web SDK FIDO2 passwordless authentication flow](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4i7p8e03foed4k6gusa1.png)
Estructura de datos: Cola
Tags: datastructure, go
Published: 2022-04-04 01:52:48

Hola!

Hace un tiempo no escribo en este portal. Me gustaría regresar con un tema fundamental de la programación, **estructuras de datos**. 

Las estructuras de datos son simplemente, formas diferentes de organizar los datos. Estas surgen de la necesidad de resolver problemas que son muy comunes o repetitivos en la labor del programador. 

Vamos a centrarnos en la **cola** o "queue" del ingles. 

La Cola, es una estructura de datos que se comporta de forma similar a una cola o fila en el banco, tomando en cuenta que en esta analogía, los datos son las personas, que llegan para ser atendidas.

Si la fila del banco esta vacía y llega una persona, pues lo más normal es que la primera persona que llegue sea la primera persona en ser atendida. Este es el principio fundamental de las colas. Primero que entra primero que sale. **Primer dato que ingresa a la cola, primer dato que sale.**

Digamos entonces, nuestra cola va a ser representada por una colección, de la siguiente forma: 

**[]**

Si viene un dato a la cola, un dato que queremos encolar, por ejemplo un numero, se vería de la siguiente forma:

**[1]**

Y si este proceso se repite algunas veces:

**[1, 2, 3]**

Tenemos una colección de 3 ítems, que se han colado haciendo fila para ser procesados, en el momento que quiera procesar los datos, debo desencolar uno. En esta ocasión al hacerlo, debería de salir el primer dato que haya sido ingresado, de la siguiente forma:

**[2, 3]**

Como podemos notar, el primer dato que ingresó fue el número 1 y este ha sido el primero que ha salido. Si repetimos el proceso, quedaría de la siguiente forma nuestra cola:

**[3]**

De nuevo, se ve cómo es que el último que ingresó a la cola es el último en ser atendido. 

Si te animas a implementar este comportamiento de cola, te animo a checar el video tutorial que he creado en Youtube. 
[Implementación de cola en golang](https://www.youtube.com/watch?v=ssqtGs9rkcg)

Gracias por leerme, Juan Miguel Arias Mejías

Te dejo mis redes: [enlace](https://linkr.bio/juanmiguelar )
Pasa bonita vida.
How To Back Up Files to S3 And Delete Them Using Bash
Tags: aws, s3, bash, backup
Published: 2022-04-04 01:26:54

---
title: How To Back Up Files to S3 And Delete Them Using Bash
published: true
description: A simple bash script to send files to S3 and then upon confirmation, delete them from the local machine.
tags: aws, s3, bash, backup
---

You have a situation. Your machine is filling up with files - could be logs, could be important data that you no longer need after sometime, and you need to get rid of them. You don't want to delete them permanently because you're unsure if you're going to need them in the future. Why not back them up to S3, which is very cheap, and at the same time delete them from the local machine?

```bash
#!/bin/bash

time_in_the_past=604800 # 1 week in seconds
directory="./"
bucket_name=""
bucket_path="/"

current_time=$(date +"%s")
while read -d '' file; do
  mtime=$(stat -c %Y $file)
  difference=$((current_time-mtime))

  if [ "$difference" -gt "$time_in_the_past" ]; then
    echo "Backing up $file"
    aws s3 cp $file s3://$bucket_name$bucket_path && unlink $file
  fi
done < <(find $directory -type f -print0)
```

This script will read the files in a directory, check that they're older than a specified time, upload them to S3 and if successfully, delete them from the local machine. This script assumes you installed and configured the [AWS CLI](https://aws.amazon.com/cli/).

There are 4 variables at the top that control how it will behave:
* **time_in_the_past** is a week in seconds, but you can change this to any value.
* **directory** is the directory where the backups will happen.
* **bucket_name** The bucket name in which the files will be uploaded. (a-z0-9_-)
* **bucket_path** The path inside the bucket where the files will be placed.

You can save this file as `cleanup.sh` and then run it every X amount of time using crontab. To open crontab, you can run

```crontab -e```

Then choose your preferred editor (I usually go for nano). Then place the crontab line at the end:

```30 6 * * sun /path/to/cleanup.sh```

The `30 6 * * sun` means every sunday at 6:30 am. You can visualize cron expressions with this amazing tool called [cron guru](https://crontab.guru/#30_6_*_*_sun).

Hope you found this useful! If you have any questions I can answer them in the comments.
Active Record Associations
Published: 2022-03-31 17:45:00

I am currently working on my first Ruby/Sinatra Application for my online software engineering program. I wanted to share what I learned about Active Record Associations and all the built in methods we get access to using it.


#`has_many`
An instance of one class that owns many instances of another class. This class must pluralize the has many instance method to get access to all the instances it owns.  _A User has many recipes_

```
class Actor < ActiveRecord::Base
    has_many :characters
end
```
```
class Show < ActiveRecord::Base
    has_many :characters
end
```
The `has_many` association gives us access to 17 methods 
```
actors
actors<<(object, ...)
actors.delete(object, ...)
actors.destroy(object, ...)
actors=(objects)
actor_ids
actor_ids=(ids)
actors.clear
actors.empty?
actors.size
actors.find(...)
actors.where(...)
actors.exists?(...)
actors.build(attributes = {})
actors.create(attributes = {})
actors.create!(attributes = {})
actors.reload
```

#`belongs_to`
An instance that is owned by the has many class. We will state the belongs to method as singular to retrieve the relationship to the unique owner class.  _A Recipe belongs to one owner_ 

```
class Character < ActiveRecord::Base
    belongs_to :actor
    belongs_to :show
end
```

To ensure reference consistency, add a foreign key to the owner column of the owned table migration. 

```
class CreateRecipes < ActiveRecord::Migration[6.1]
  def change
    create_table :characters do |t|
      t.belongs_to :actor
      t.belongs_to :show
    end
  end
end
```

The `belongs_to` association gives us access to 8 methods 

```
character
character=(character)
build_character(attributes = {})
create_character(attributes = {})
create_character!(attributes = {})
reload_character
character_changed?
character_previously_changed?
```

#`has_many through:`

This creates a relationship bridge between two owner classes' and the owned/connecting class
```
class Show < ActiveRecord::Base
    has_many :characters
    has_many :actors, through: :characters
end
```
I wouldn't write a test for that
Tags: testing, tdd
Published: 2022-11-23 05:58:26

---
title: I wouldn't write a test for that
published: true
date: 2022-04-04 00:00:00 UTC
tags: [testing, tdd]
canonical_url: https://philip-weinke.de/2022/04/i-wouldnt-write-a-test-for-that/
---

Last week, I was helping a colleague who was working on a small application. One component was responsible for sending data to a configured recipient. I suggested writing a test to verify that an email was actually sent containing the relevant data in the body. This led to the following discussion:

X: “What? No, I wouldn’t write a test for that.”
Me: “Why not?”
X: “Because we would be testing third-party code.”
Me: “No, we would be testing that our component does what it’s supposed to do.”
X: “Can’t we just mock the mail library?”
Me: “In that case, I’d rather not write a test. I really want to see that it happens.”
X: “I don’t know. It feels wrong.”
Me: “How would you verify that it actually sends the mail then?”
X: “Well, I already installed the mail library, wrote a little test script, spun up a mailhog, and checked that there was a mail in the inbox …”
Me: “… so you kind of did the test I’m suggesting. Manually. One time.”

I guess his approach isn’t that unusual. You write some code to figure out how a new library works, and when you’re confident enough, you integrate it. You save writing a test, because you use a third-party library that just works™. I’m sure it does, but still… I want to see proof.

As I stated in the discussion, it’s not about testing that library. It’s about that our code works as intended, no matter what the implementation looks like. If I upgrade the library to a new version, I want to be sure that it still works. If I switch to a different library, I want to be sure that it works the same as before. Maybe it’s just me, but I really like having that confidence.

So, next time you don’t want to write a test because it’s some lib that just works, plus you just checked it manually: give it a try and automate it anyway. It’s not that hard. (_In our case, it was hard. We spent about an hour in some weird jest/javascript hell until the test passed. I really don’t know how people get shit done with javascript_)
What if the stakeholder can't work in an agile way?
Tags: agile, business
Published: 2022-09-25 09:55:52

---
title: What if the stakeholder can't work in an agile way?
published: true
date: 2022-04-04 00:00:00 UTC
tags: agile,business
canonical_url: https://jhall.io/archive/2022/04/04/what-if-the-stakeholder-cant-work-in-an-agile-way/
---

If we agree that [software development is unpredictable](https://jhall.io/archive/2022/02/18/software-development-is-inherently-unpredictable/), and we agree that this means we need to deal with stakeholders in a [different way](https://jhall.io/archive/2022/04/02/so-do-you-expect-me-to-write-a-blank-check/), what do we say to stakeholder who refuse to work in an agile way?

Well, countless projects _do_ operate this way. What happens to them?

Well, the vast majority of them (estimates range from 50 to 80%) fail in one way or another:

- They run over schedule
- They run over budget
- They are full of bugs
- They get cancelled before they’re completed
- They are released, but with a very limited scope
- They are released, but fail to meet the needs of the intended user

* * *
_If you enjoyed this message, [subscribe](https://jhall.io/daily) to <u>The Daily Commit</u> to get future messages to your inbox._
Announcing the Devs For Ukraine Conference
Tags: ukraine, conference, free, charity
Published: 2022-04-04 20:41:45

---
title: Announcing the Devs For Ukraine Conference
published: true
date: 2022-04-04 00:00:00 UTC
tags: ukraine, conference, free, charity
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0ggfqj1p61ptwfpou9zz.png
canonical_url: https://blog.remote.com/blog/devs-for-ukraine-conference
---

In February 2022, Russia and its forces senselessly attacked Ukraine. The violence and the suffering inflicted on the people in Ukraine is very real. We want to help.

## Introducing [Devs For Ukraine](https://www.devsforukraine.io/), a free, online charity conference with the goal of raising funds and providing support to Ukraine.

On April 25th and 26th, join 17 speakers from around the globe to learn about career growth, team leadership, tech’s ability to create a more equitable world, and more.

Our goal for the event is to raise $15,000 for these non-governmental organizations:

- [Come Back Alive](https://www.comebackalive.in.ua/)
- [Razom For Ukraine](https://razomforukraine.org/)
- [Red Cross](https://redcross.org.ua/en/2022/02/donate-to-support-the-ukrainian-red-cross-to-help-civilians-in-this-difficult-time-for-ukraine/)
- [Polski Czerwony Krzyż (PCK)](https://pck.pl/na-pomoc-ukrainie/)
- [Voices of Children](https://voices.org.ua/en/)
- [Polska Akcja Humanitarna (PAH](https://www.pah.org.pl/sos-ukraina/))
- [Insight Ukraine](https://www.insight-ukraine.org/en/)
- [Coalition To Support Black People In Ukraine](https://www.gofundme.com/f/support-vulnerable-black-people-in-ukraine)

The event will be free to attend and is run by volunteers, but we ask everyone to donate. **All of the funds will be donated to the benefit of Ukraine.**

## How you can help

If you’d like to help our cause, you can:

- [Register to attend](https://www.devsforukraine.io/)
- Share this event with your communities ([click here to tweet](https://twitter.com/intent/tweet?text=I%27m%20going%20to%20DevsForUkraine,%20a%20free%20conference%20to%20benefit%20Ukraine%20with%2017%20awesome%20speakers!%20Will%20I%20see%20you%20there?&url=devsforukraine.io))
- [Donate directly](https://www.devsforukraine.io/?modal=donate)

We’re looking forward to seeing you at the event!