Community Chat & Live Help
Ask a New Question!
Public Discussions (13)
How you would call the function upTop() from the command line ?
labhak0@PC-AITWAHNIZ:~/ic-projects/DBank-Hanifi-Algeria$ dfx canister call DBank-Hanifi-Algeria-backend topUp (enter)
This method requires arguments.
✔ Enter a float64 · 50000
Sending the following argument:
(50000.0 : float64)
Do you want to send this message? [y/N]
y
(350004.92771751207 : float64)
labhak0@PC-AITWAHNIZ:~/ic-projects/DBank-Hanifi-Algeria$
1. La "Banque" (Smart Contract)Dépôt réel : Tu peux injecter des fonds avec topUp.Retrait intelligent (withdraw) : Tu peux retirer ton argent. Le contrat calcule automatiquement tes intérêts gagnés jusqu'à la seconde près avant de te rendre le montant.Intérêts composés : Le calcul suit la formule $A = P(1+r)^t$ avec un taux annuel de 3,25%.2. La Sécurité (Authentification)Ton Principal ID (ajbag-...) est gravé dans le code comme administrateur unique.Grâce à shared(msg), personne d'autre que toi ne peut utiliser la fonction resetTimer. Ton identité blockchain est ton mot de passe.3. L'outil de Simulation (Marketing)Tu as une fonction simulatePastDeposit qui ne touche pas au solde réel.Elle permet de montrer à un client : "Si tu avais mis 1 000 000 DA en 2019, tu aurais aujourd'hui 1 247 939 DA". C'est l'argument de vente parfait.4. La Maîtrise du TempsOn a abandonné la modification manuelle de la date (qui créait des erreurs de synchronisation) pour utiliser le temps réel de la blockchain.Le système est maintenant "propre" et ne nécessite plus de bidouillage pour fonctionner.
import Time "mo:base/Time";
import Float "mo:base/Float";
import Principal "mo:base/Principal";
import Int "mo:base/Int";
persistent actor DBank {
var currentValue : Float = 0.0;
var lastUpdateTimestamp : Int = Time.now();
// Ta clé admin pour la sécurité
let admin : Principal = Principal.fromText("ajbag-mbh7x-n4xf1-rbrf4-vzkkw-ziree-3miu3-i4mlb-dziwb-zwnsc-eqe");
let annualRate : Float = 0.0325; // Taux de 3.25%
let secondsInYear : Float = 31_536_000.0;
// --- LOGIQUE INTERNE ---
private func applyInterest() {
let currentTime = Time.now();
let secondsElapsed = Float.fromInt((currentTime - lastUpdateTimestamp) / 1_000_000_000);
if (secondsElapsed > 0) {
let yearsElapsed = secondsElapsed / secondsInYear;
currentValue := currentValue * Float.pow(1.0 + annualRate, yearsElapsed);
lastUpdateTimestamp := currentTime;
};
};
// --- FONCTION DE RETRAIT (DRAW) ---
public func withdraw(amount : Float) : async Float {
applyInterest();
if (amount <= currentValue) {
currentValue -= amount;
};
return currentValue;
};
// --- FONCTION DE DÉPÔT ---
public func topUp(amount : Float) : async Float {
applyInterest();
currentValue += amount;
return currentValue;
};
// --- CONSULTATION SOLDE ---
public query func checkBalance() : async Float {
let currentTime = Time.now();
let secondsElapsed = Float.fromInt((currentTime - lastUpdateTimestamp) / 1_000_000_000);
let yearsElapsed = secondsElapsed / secondsInYear;
return currentValue * Float.pow(1.0 + annualRate, yearsElapsed);
};
// --- TEMPS ÉCOULÉ (DYNAMIQUE) ---
// Affiche le temps qui défile entre le dernier enregistrement et maintenant
public query func getElapsedTime() : async Text {
let now = Time.now();
let diff = (now - lastUpdateTimestamp) / 1_000_000_000;
let days = diff / 86_400;
let hours = (diff % 86_400) / 3_600;
let minutes = (diff % 3_600) / 60;
let seconds = diff % 60;
return "Temps écoulé : " #
Int.toText(days) # "j " #
Int.toText(hours) # "h " #
Int.toText(minutes) # "m " #
Int.toText(seconds) # "s";
};
// --- SIMULATION PAR DATE (POUR LES CLIENTS) ---
public query func simulatePastDeposit(amount : Float, year : Int, month : Int, day : Int) : async {
total : Float;
profit : Float;
yearsElapsed : Float;
} {
let currentTime = Time.now();
let yearSec = (year - 1970) * 31_536_000;
let monthSec = (month - 1) * 2_628_000;
let daySec = (day - 1) * 86_400;
let chosenTimestamp = (yearSec + monthSec + daySec) * 1_000_000_000;
let secondsDiff = Float.fromInt((currentTime - chosenTimestamp) / 1_000_000_000);
let yearsElapsed = secondsDiff / secondsInYear;
if (yearsElapsed > 0) {
let finalAmount = amount * Float.pow(1.0 + annualRate, yearsElapsed);
return {
total = finalAmount;
profit = finalAmount - amount;
yearsElapsed = yearsElapsed;
};
} else {
return { total = amount; profit = 0.0; yearsElapsed = 0.0 };
};
};
// --- RÉINITIALISATION (ADMIN SEULEMENT) ---
public shared (msg) func resetTimer() : async Text {
if (msg.caller != admin) { return "Accès refusé" };
applyInterest();
lastUpdateTimestamp := Time.now();
return "Compteur synchronisé avec l'heure réelle.";
};
};
ICP SDK (dfx) Motoko on WSL2(Ubuntu). Où s'affiche le Debug.print ?
Le message que tu as écrit à la ligne 12 s'affiche uniquement dans ton terminal, et seulement au moment du déploiement.
Regarde bien ton terminal où tu as lancé dfx start (celui de gauche sur image_263f36.png).
Si tu as beaucoup de lignes, le message est peut-être remonté.
Astuce : Pour le voir réapparaître, tape dfx deploy --upgrade-unchanged. Cela forcera le redémarrage de l'actor et déclenchera le Debug.print.
2. Pourquoi Candid n'affiche pas de date ?
Candid affiche uniquement les retours des fonctions que tu appelles manuellement. Ton Debug.print envoie une info au terminal "serveur", pas à l'interface web. import Time "mo:base/Time";
import Float "mo:base/Float";
import Debug "mo:base/Debug";
import Int "mo:base/Int";
persistent actor DBank {
// --- VARIABLES D'ÉTAT ---
var currentValue : Float = 0.0;
var lastUpdateTimestamp : Int = Time.now();
// Ce print s'affichera dans le terminal où tu as fait "dfx start" au déploiement
Debug.print("Initial lastUpdateTimestamp: " # Int.toText(lastUpdateTimestamp));
// Paramètres (3.25% par an)
let annualRate : Float = 0.0325;
let secondsInYear : Float = 31_536_000.0;
// --- LOGIQUE INTERNE ---
private func applyInterest() {
let currentTime = Time.now();
// On convertit la différence de nanosecondes en secondes (Float)
let secondsElapsed = Float.fromInt((currentTime - lastUpdateTimestamp) / 1_000_000_000);
if (secondsElapsed > 0) {
let yearsElapsed = secondsElapsed / secondsInYear;
// Formule des intérêts composés : A = P * (1 + r)^t
currentValue := currentValue * Float.pow(1.0 + annualRate, yearsElapsed);
lastUpdateTimestamp := currentTime;
};
};
// --- FONCTIONS PUBLIQUES (VISIBLES DANS CANDID) ---
public func topUp(amount : Float) : async Float {
applyInterest();
currentValue += amount;
return currentValue;
};
public func withdraw(amount : Float) : async Float {
applyInterest();
if (amount <= currentValue) {
currentValue -= amount;
} else {
Debug.print("Solde insuffisant !");
};
return currentValue;
};
public query func checkBalance() : async Float {
let currentTime = Time.now();
let secondsElapsed = Float.fromInt((currentTime - lastUpdateTimestamp) / 1_000_000_000);
let yearsElapsed = secondsElapsed / secondsInYear;
return currentValue * Float.pow(1.0 + annualRate, yearsElapsed);
};
// Nouvelle fonction pour voir la date stockée en nanosecondes
public query func getLastTimestamp() : async Int {
return lastUpdateTimestamp;
};
// --- OUTILS DE TEST ---
public func backdateLastUpdate(year : Int, month : Int, day : Int) : async Text {
// Calcul très simplifié du timestamp UNIX
let yearSec = (year - 1970) * 31_536_000;
let monthSec = (month - 1) * 2_628_000;
let daySec = (day - 1) * 86_400;
lastUpdateTimestamp := (yearSec + monthSec + daySec) * 1_000_000_000;
return "Date modifiée au " # Int.toText(day) # "/" # Int.toText(month) # "/" # Int.toText(year);
};
};
SUSDB, c’est quoi ?
SUSDB est la base de données utilisée par WSUS (Windows Server Update Services).
Elle contient toutes les métadonnées nécessaires pour gérer les mises à jour Windows au sein d’un réseau (catalogue des updates, états d’approbation, inventaire des machines, rapports, etc.).
Produit concerné : WSUS (intégré ou autonome, parfois sous-jacent à Microsoft Endpoint Configuration Manager/SCCM).
Moteurs possibles :
WID (Windows Internal Database) par défaut lors d’une installation WSUS simple.
SQL Server (Express/Standard/Enterprise) si vous choisissez/avez migré vers SQL.
Nom de la base : SUSDB
Fichiers (WID) : C:\Windows\WID\Data\SUSDB.mdf et SUSDB_log.ldf (emplacement par défaut).
Contenu des mises à jour (binaires .cab/.msu) : pas dans SUSDB — stockés dans le dossier WSUSContent (ex. C:\WSUS\WsusContent ou un volume dédié).WID (local uniquement) :
Server name = np:\\.\pipe\Microsoft##WID\tsql\query
Auth = Windows, SSMS Admin, ouvrir SSMS sur le serveur WSUS.
Security-SPP, c’est quoi ?
Security-SPP est le nom que vous voyez dans l’Observateur d’événements (Event Viewer) pour la plateforme de protection logicielle de Microsoft :
Service Windows : Software Protection
Nom de service : sppsvc
Processus : sppsvc.exe (situé dans C:\Windows\System32\)
Ce composant gère l’activation et les licences de Windows et de certains produits Microsoft (notamment via KMS/MAK/digital license). Il vérifie que votre système et vos applications sont correctement licenciés, stocke/valide les jetons de licence, et renouvelle les activations quand c’est nécessaire (ex. KMS).
What is the Compound Protocol?
Compound is a decentralized finance (DeFi) protocol built on the Ethereum blockchain that allows users to lend and borrow cryptocurrencies without using a traditional bank or intermediary.
It operates entirely through smart contracts, making it non-custodial, transparent, and permissionless.
What's hashing?
It's basically a mathematical formula that allows you to turn a message into a Hash code by passing the message through the hash function. But unlike encryption, a hash is a bunch of mumbo jumbo but if you use the same hash function, no matter what message you put in, you will always get an output with the same number of characters. If you hashed abc and 123 you might get this bottom result. 45dbaf8529d52c6 3bc4g3a4fb34j5b but they both have the same number of characters.
Movable-type.co.uk/scripts/sha256.html
What exactly is web3 anyways?
Well, it's basically the new internet. Web3. 0 describes the third iteration or the third sort of stage of the Web.
What is Web3?
Internet 1970.
WEB 1990
Web1.0 1995 it was a read-only web.
Web2.0 2005 became interactive this is your Facebook, your X, your Instagram... The user, interact with them, read and we can also write.
Web3.0 2018 applications on the Blockchain...and this is the dawn of Web 3.0 cryptocurrencies if you think you can predict the future, the this is probably the path to go down. For example, Helium is a really popular web3 project, which is providing wireless internet to out of the way places through individual people hosting their 5G network and owning cryptocurrency or PoolTogether, which lets you participate in no loss lotteries.
Qu’est-ce que pgAdmin 4 ?
Data Persistence: Interface web (accessible via navigateur) ou desktop pour PostgreSQL.
Permet de créer, modifier et gérer :
Bases de données
Tables, vues, fonctions
Utilisateurs et rôles
Inclut un éditeur SQL, un explorateur d’objets, et des outils de sauvegarde/restauration.
API avec Postman : c'est quoi ?
API (Application Programming Interface) : Un ensemble de règles permettant à deux applications de communiquer.
Postman : Un outil graphique qui sert à tester, envoyer et automatiser des requêtes HTTP vers une API (GET, POST, PUT, DELETE…).my Own API in khelaf-hanifi.com/dev-api
Qu’est-ce qu’Axios et à quoi sert-il dans le développement web, notamment avec React.js ?
Axios est une bibliothèque JavaScript qui sert à faire des requêtes HTTP (GET, POST, PUT, DELETE…) depuis le navigateur ou Node.js.
Comment reagir avec input AI ?
Un input clair, net et précis est le carburant de l’IA.( Clear, precise input is the fuel that powers AI. ).