how save data from different account using web3 py to smart contract

0 votes

The project is a group of Ethereum users, who want to send their data to the blockchain network to be saved, this data is sent by those users by Python. As I understood that each user has an address that sends his data through this address in order to save the data.
Python will be used to send data. My question is how will I specify the addresses that will send the data in the Python file?
Or how will more than one user (the address) call the job in the smart contract?
I don't want to send Ether from more than one address
I am a beginner in this topic!
If the answer can be explained with a code, and if it is explained by sending a random number to simplify the problem by many users for example in web3.py  

pragma solidity ^0.4.18;

contract Courses {
    address owner;
    
    function Owned() public {
        owner = msg.sender;
    }
    
   modifier onlyOwner {
       require(msg.sender == owner);
       _;
   }
   
    
        
    struct Server{
          uint data;
          uint num;
         
               
    }
       
    mapping (address => Server) servers;
    address[] public serveracct; 
    uint[] public datta;    
    
    function set_data (uint _num, uint _data  ) public {
        
         servers[msg.sender].data = _data;
         servers[msg.sender].num = _num;
         datta.push(_num);
         datta.push(_data);
         
          serveracct.push(msg.sender);
    }
    
     function getser() view public returns (uint, uint) {
        return ( servers[msg.sender].data, servers[msg.sender].num );
    }
    
    
Jul 14, 2020 in Blockchain by anonymous
• 120 points

edited Jul 14, 2020 by Gitika 1,524 views

2 answers to this question.

0 votes

Hi, @Amal

Here’s an example of how to send a MIME message containing a bunch of pictures that may be residing in a directory:

# Import smtplib for the actual sending function
import smtplib

# And imghdr to find the types of our images
import imghdr

# Here are the email package modules we'll need
from email.message import EmailMessage

# Create the container email message.
msg = EmailMessage()
msg['Subject'] = 'Our family reunion'
# me == the sender's email address
# family = the list of all recipients' email addresses
msg['From'] = me
msg['To'] = ', '.join(family)
msg.preamble = 'You will not see this in a MIME-aware mail reader.\n'

# Open the files in binary mode.  Use imghdr to figure out the
# MIME subtype for each specific image.
for file in pngfiles:
    with open(file, 'rb') as fp:
        img_data = fp.read()
    msg.add_attachment(img_data, maintype='image',
                                 subtype=imghdr.what(None, img_data))

# Send the email via our own SMTP server.
with smtplib.SMTP('localhost') as s:
    s.send_message(msg)

I hope this will be helpful.

answered Jul 28, 2020 by Gitika
• 65,770 points
0 votes

Hey, @Amal,

It will automatically take the address once you invoke the function as you have used msg.sender.

answered Jul 28, 2020 by Rajiv
• 8,870 points

Related Questions In Blockchain

0 votes
1 answer

How to access member functions of smart contract using web3?

I have implemented a similar feature and ...READ MORE

answered Aug 13, 2018 in Blockchain by slayer
• 29,370 points
1,595 views
0 votes
1 answer
+1 vote
2 answers
+1 vote
1 answer
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,923 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,451 views
0 votes
2 answers
0 votes
1 answer

How to create an instance of contract in Truffle console?

Hi, @There, I would suggest you go through ...READ MORE

answered Jun 17, 2020 in Blockchain by Gitika
• 65,770 points
2,020 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP